powerpoint hang vba, vb unstable?

G

Guest

I've got a pretty simple app I've tried writing within powerpoint as a set of
vba procedures and also as an add-in and yet again as a visual basic exe that
calls out to powerpoint. I can provide the code if needed but I was just
wondering if there is a known issue that powerpoint has a memory leak or just
hangs if you have large ( 150-200 slide) presentations. My code is simply
trying to change the absolute links in shapes to relative links but the code
fails randomly even if I'm just stepping through every slide in a loop and
then stepping through every shape without actually doing anything. Note
that this code was failing even before I put in the recursive HandleGroup
routine and none of the slides has grouping more than 2 or 3 levels.

in pseudo code I'm just doing the following....

....
Set theView = p.Windows(1).View

For Each sld In p.Slides
theView.GotoSlide sld.SlideIndex

For Each shp In sld.Shapes
If (shp.Type = msoGroup) Then
HandleGroup p, shp.GroupItems
Else
HandleShape p, shp
End If
Set shp = Nothing
Next 'shape
Set sld = Nothing
Next 'slide
......

Sub HandleGroup(p As Presentation, theGroup As GroupShapes)
Dim shp As Shape
For Each shp In theGroup
If (shp.Type = msoGroup) Then
HandleGroup p, shp.GroupItems
Else
HandleShape p, shp
End If
Next 'shp
End Sub

Sub HandleShape(p As Presentation, shp As Shape)
Dim theFlash As ShockwaveFlash
If shp.Type = msoMedia Then
If shp.MediaType = ppMediaTypeMovie Then
Call Handlemovie(p, shp) ' make the path to the movie file
relative
End If 'shp.mediatype
ElseIf shp.Type = msoOLEControlObject Then
If InStr(1, shp.OLEFormat.ProgID, "flash", vbTextCompare) Then
Set theFlash = shp.OLEFormat.Object
Call HandleFlash(p, theFlash) 'make the path to the flash movie
relative
End If
End If 'shp.type

End Sub

I'm pretty sure that I've not got any leaks (i.e any objects I "set" to
nothing as soon as I'm through with them)

Sometimes I can run the macro once , sometimes twice very rarely 3 times
before powerpoint either hangs, or just puts up a dialog saying it has run
into an unexpected error.

Another thing I've noticed is when I get that powerpoint "unexpected error"
dialog , after quitting powerpoint from file/exit. If I go into the task
window there is still a powerpoint process running though there is NOT one
running with any user interface that I can see.

thanks for any tips.
 
D

David M. Marcovitz

I don't know of any problems like the one you described, but Steve is the
expert on this since he has already done it (see his FixLinks tool). I'm
not sure you need to set the objects to nothing because your For Each
loops should automatically change the value of shp and sld as needed, and
because they are local variables, they will go away when you exit the
procedure.

I would try eliminating some of the types you handle to see if any of
those are a problem. That is, start with the simplest thing (you already
mentioned that this problem happened before you added groups, so take
away groups and other things to see if you can find one thing that causes
the problem).

--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top