VBA in 2007 crashes

B

Bits-n-PCES

I have VBA code that generates Powerpoint slides and populates presenter
notes. With one function I am placing ten different pictures on one slide as
a stack that i then animate having one appear over the other on mouseclick.
The VBA code adds the pictures with their animation effects just fine.
Usually in the slide right after that as it is about to populate the
presenter notes with text, PowerPoint 2007 will crash. Powerpoint 2003 has
no problem with the same code. The graphics are 800x600 and are about 100k
each. Could there be a memory problem in 2007 that is causing this?
 
G

Glen Millar

Hi,

I guess to really know we'd need to see some code.

--

Regards,
Glen Millar
Microsoft PPT MVP

Please tell us your PowerPoint version

Tutorials and PowerPoint animations at
the original www.pptworkbench.com
glen at pptworkbench dot com
 
B

Bits-n-PCES

This is the code that does the graphics. It does not always crash in the same
place, but usually fails after building this slide. Also after saving and
closing the presentation, I cannot get it to quit() (I open the PPT
application from Word VBA and no other presentations are open).

Public Sub cascade(myDoc As PowerPoint.Presentation, mySlide As
PowerPoint.Slide, arrGraphics() As typXTGraphic, bErase As Boolean, bFade As
Boolean, Optional intOffset As Integer = 0)
Dim myShape As PowerPoint.Shape
Dim oldshape As PowerPoint.Shape
'Dim tline As PowerPoint.TimeLine
Dim xtGraphic_rec As typXTGraphic
Dim rectShape As typRect
Dim rectGraphic As typRect
Dim myEntryEffect As PpEntryEffect
Dim myExitEffect As PpAfterEffect
On Error GoTo cascade_err
Set myShape = getShapewithTag(mySlide, "ppTag", "c1")
'establish the graphic's rectangle space by the shape dimensions
rectShape = setBoundsbyShape(myShape)

'removed the conditional for determining effect
myEntryEffect = ppEffectFade
myExitEffect = ppAfterEffectDim

torig = rectShape.T
lorig = rectShape.L
For i = 1 To UBound(arrGraphics)
strName = MergeReplace(myDoc.FullName, myDoc.Name, "graphics\" &
arrGraphics(i).Graphic_name)
Set myShape = mySlide.Shapes.AddPicture(FileName:=strName,
LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=lorig + (i * offset),
Top:=torig + (i * offset), width:=arrGraphics(i).Graphic_Width,
height:=arrGraphics(i).Graphic_Height)
With rectShape
.T = .T + (intOffset)
.L = .L + (intOffset)
.W = .W - (intOffset)
.H = .H - (intOffset)
End With

sizeGraphictoPlaceHolder myShape, arrGraphics(i).Graphic_Width,
arrGraphics(i).Graphic_Height, rectShape
rectGraphic = setBoundsbyShape(myShape)
'if it is not offset then center it in the placeholder space
If intOffset = 0 Then
placeGraphic mySlide, myShape, rectShape, rectGraphic
Else
myShape.Left = rectShape.L
myShape.Top = rectShape.T
End If

With myShape.AnimationSettings
.Animate = msoTrue
.EntryEffect = myEntryEffect
.AdvanceMode = ppAdvanceOnClick
End With Set oldshape = myShape

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'next timing section commented until we can fix the crash
' With tline.MainSequence
' With .AddEffect(myShape, myEntryEffect)
' .Timing.Speed = 1
' End With
' If (i > 1) And (myExitEffect > 0) Then
'
' With .AddEffect(oldshape, myExitEffect)
' .Timing.TriggerType = msoAnimTriggerWithPrevious
' If (Not (bOffset)) Then .Exit = msoTrue
' End With
' End If
' End With
' Set oldshape = myShape
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
myDoc.Save
Next

Exit Sub
cascade_err:
MsgBox Err.Description
Resume Next
End Sub
 
J

John Wilson

Are you sure 2003 works with that code?

Animation settings is left over from pre 2002 PowewrPoint and cannot be used
for animations not present in 2000 (ie any exits)

You need to use some after this fashion using the new timeline
Set oeff = myslide.TimeLine.MainSequence.AddEffect _
(oshp, msoAnimEffectAppear, , msoAnimTriggerOnPageClick)

For exits set oeff.Exit=True


--
Amazing PPT Hints, Tips and Tutorials

http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
_______________________________

We''re at PPTLive - see you there?
www.pptlive.com
 
B

Bits-n-PCES

Thanks for your response John. There are a couple of things I need to
mention about that code: 1. the aftereffects were working in 2007 but when I
generated them using the office12 ppt olb, it crashed after building a number
of slides. 2. notice that the timeline code is commented out. The aftereffect
is never called in the animationsetting code. Although i wanted to use it I
could only do so using the timeline method. 3, there was a pasting error in
the line with " set oldshape = myshape" ( there is a line feed that was
clipped off).
I still think it is related to memory management: I have 10 pictures I am
generating into one slide. When I reduced it to 6 pictures it crashed less
frequently but still crashed. It frequently completes ALL the slide
generation including slides built after the multiple picture slide, and then
crashes on the quit() command. It stays open after the call to quit() and
then pops up "Sorry powerpoint encountered a problem and has to quit...."
 

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