This error is driving me nuts. The code below will run perfectly when
it has a breakpoint. But as soon as I remove the breakpoint and run it
normally outside of debug mode I get a strange error message that says:
"Microsoft Office PowerPoint has encountered a problem and needs to
close. We are sorry for the inconvience.
If you were in the middle of something, the information you were
working on might be lost."
If any one can help with this I really would appreciate. Here is the
code:
Function CreatePowerPointCatiaImage(vbFilePath As String)
Dim ppApp As PowerPoint.Application
Dim mySlide As PowerPoint.Slide
Dim mytShape As PowerPoint.Shape
Dim shpCurrShape As PowerPoint.Shape
Dim myDocWin As PowerPoint.DocumentWindow
Dim myPicture As String
Dim path As String
Dim vbFilePath2 As String
Dim prsPres As PowerPoint.Presentation
Dim IStartedppApp As Boolean
vbFilePath2 = "c:\winnt\temp\CatiaImage.ppt"
' Noice the extra slashes
If ppApp Is Nothing Then
Set ppApp = New PowerPoint.Application
IStartedppApp = True
End If
'ppApp.Activate 'this flashes powerpoint onscreen can't hide it per
vberror
With ppApp
Set prsPres = .Presentations.Add(msoTrue)
With prsPres
Set mySlide = .Slides.Add(.Slides.Count + 1, ppLayoutBlank)
With mySlide
mySlide.Shapes.AddPicture vbFilePath, msoFalse, msoTrue,
50, 30, 600, 480
End With
' With ppApp 'must use Activate as shown above
' ppApp.ActiveWindow.ViewType = ppViewSlide
' End With
If FileExists(vbFilePath2) Then
Kill (vbFilePath2)
End If
prsPres.SaveCopyAs vbFilePath2
'ppApp.Quit 'Quit PowerPoint - if you have a command after it will not
End With
End With
If IStartedppApp Then ppApp.Quit
Set ppApp = Nothing
Set mySlide = Nothing
Set mytShape = Nothing
Set shpCurrShape = Nothing
Set myDocWin = Nothing
End Function