Help with PPT AddIn that pastes slides into another presentation
Hi
We have a small PPT addin which works fine on Office 2003 but for some reason doesn't quite work in PPT 2010. What the AddIn does is opens a 'template' presentation (TheFileName), copies the relevant slide (theslide) onto the clipboard, closes the template presentation & then pastes the slide into the original presentation. This works fine in PPT 2003 but when run in 2010 the copy & paste function works fine but then the ribbon becomes unresponsive (until you flick to another application on the taskbar & then back). Also, if you try run the AddIn again the form which the user uses to select which slide they want to insert is completely blank which suggests to me that the AddIn never seems to finish what its doing.
This is the code I'm using:
Sub insertSlide(theFile As String, theSlide As Integer)
Dim TheFileName As String
TheFileName = "C:\Optimisa_PPT_Toolbar\Content\files\" & theFile
Presentations.Open FileName:=TheFileName
ActivePresentation.Slides(theSlide).Copy
With Application.Presentations(TheFileName)
.Saved = True
.Close
End With
If PowerPoint.Application.Version >= 9 Then
'window must be visible
PowerPoint.Application.Visible = msoTrue
End If
On Error GoTo PROC_ERR
ActiveWindow.View.Paste
PROC_ERR:
If Err = "-2147188160" Then
Dim ppApp As PowerPoint.Application
Set ppApp = CreateObject("Powerpoint.Application")
' Make it visible.
ppApp.Visible = True
' Add a new presentation.
Dim ppPres As PowerPoint.Presentation
Set ppPres = ppApp.Presentations.Add(msoTrue)
' Add a new slide.
Dim ppSlide1 As PowerPoint.Slide
Set ppSlide1 = ppPres.Slides.Add(1, ppLayoutText)
ActiveWindow.View.Paste
End If
End Sub
Any ideas as to why this works with PPT 2003 but seems to throw up some random problems (Ribbon freezing & unable to run AddIn again) in PPT 2010 would be much appreciated.
Thanks
Matt
|