2010 office beta - vba code is not working for paste slide

  • Thread starter Thread starter XStream
  • Start date Start date
X

XStream

We are using some vb code to copy slides from one power point presentation to
another. The code is working properly with the previous office versions
(2007, XP etc). But, for office 2010 the code to paste slide to the
destination presentation is not working. It shows an error message:



"Run-time error '-2147417851 (80010105)':

Method 'Paste' of object 'Slides' failed"



Please find attached PowerPoint2010-Error.JPG also.



Code used to copy and paste the slides is as follows:



Dim oSource As Presentation

Dim oTarget As Presentation

Dim oSlide As Slide

Dim pSlide As Slide



Dim insertposition As Integer



Set PPTApp = CreateObject("PowerPoint.Application")

With PPTApp

.Visible = True



Set oTarget = PPTApp.Presentations.Open(FileName:="D:\\PPT\\Dest.ppt",
WithWindow:=msoFalse)

Set oSource = PPTApp.Presentations.Open(FileName:="D:\\PPT\\Source.ppt",
WithWindow:=msoFalse)



insertposition = 1



For Each oSlide In oSource.Slides

oSlide.Copy

With oTarget.Slides.Paste(insertposition) ‘ error occured

.Design = oSlide.Design

.ColorScheme = oSlide.ColorScheme

insertposition = insertposition + 1

End With

Next oSlide

oSource.Close

oTarget.Save

oTarget.Close

Set oSource = Nothing



End With
 
XStream said:
We are using some vb code to copy slides from one power point presentation
to
another. The code is working properly with the previous office versions
(2007, XP etc). But, for office 2010 the code to paste slide to the
destination presentation is not working. It shows an error message:



"Run-time error '-2147417851 (80010105)':

Method 'Paste' of object 'Slides' failed"



Please find attached PowerPoint2010-Error.JPG also.



Code used to copy and paste the slides is as follows:



Dim oSource As Presentation

Dim oTarget As Presentation

Dim oSlide As Slide

Dim pSlide As Slide



Dim insertposition As Integer



Set PPTApp = CreateObject("PowerPoint.Application")

With PPTApp

.Visible = True



Set oTarget = PPTApp.Presentations.Open(FileName:="D:\\PPT\\Dest.ppt",
WithWindow:=msoFalse)

Set oSource = PPTApp.Presentations.Open(FileName:="D:\\PPT\\Source.ppt",
WithWindow:=msoFalse)



insertposition = 1



For Each oSlide In oSource.Slides

oSlide.Copy

With oTarget.Slides.Paste(insertposition) ‘ error occured

.Design = oSlide.Design

.ColorScheme = oSlide.ColorScheme

insertposition = insertposition + 1

End With

Next oSlide

oSource.Close

oTarget.Save

oTarget.Close

Set oSource = Nothing



End With

Remember that Microsoft does not monitor these newsgroups for errors or bug
reports. That is what the Send a frown is used for that should be in your
system tray once you installed Office 2010 Beta. That is the only way you
are going to get bug reports to Microsoft.
 
XStream

Declaring Slides and Presentations (rather that PowerPoint.Slide) sort of
infers your code is within PPT???

If so why create a new ppt application object?

Pre 2010 this will be ignored as you can only have one application object
but in 2010 it WILL create a new application instance. Having said that it
still works here except that ‘ error occured seems to be incorrectly
commented which may be a browser problem but it does error if I copy paste
your code.
 
Back
Top