Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Syntax for PowerPoint VBA to invoke a Trigger

Posted on 2008-06-12
Medium Priority
Last Modified: 2016-04-12
I want to invoke an animation trigger from VBA during a PowerPoint SlideShow.

I can't come up with the correct sytax to do this invocation ...

something like, I don't know,

ActivePresentation.Slides(mySlide.Name).shapes(MyTriggerShape.Name).ActionSettings.Item(ppMouseClick).ActionSomething?  Or something else?

Question by:canesbr
  • 7
  • 5
LVL 21

Expert Comment

ID: 21775281

Author Comment

ID: 21775800
Excuse me - the other question was being neglected.
You seem peeved??

You point to the attached code example
No, this is not it at all.
That example sets up a rectangle with a diamond effect that will execute after a click. (The 'trigger' here refers to Click(Page) or With or After(none))
This is not the same as the 'trigger' I am talking about

Run the example macro. (Ignore the error it causes) This is equivalent to adding the following manually
SlideShow>Custom Animation& >Rectangle x>Timing>Start>On Click

But, now, bear with me. Add Oval 1 manually, then
Slide Show>Custom Animation& >Rectangle x>Timing>Triggers>Start Effect on Click of:>Oval 1

You will then see a grey box above Rectangle x in the Custom Animation Task Pane
Trigger: Oval y

When you go into View>SlideShow and you click on the Oval, it will start the Diamond motion path for the Rectangle.

So, you can now see that the nomenclature is confusing  the 'Trigger' <<BUTTON>> in the Timing Tab of the Animation Dialog is, I believe, NOT the same as the word 'trigger' in the timing START options, which are variously
msoAnimTriggerOnPageClick Default.
Also I think that the example error is caused because the msoAnimTriggerOnShapeClick is out of context here. only the PageClick is valid without a Trigger *button* in the setup

Now, so, it is NOT the VBA code to SET UP the animation trigger in the Normal Edit View that I am talking about, I am looking for the code during the SLIDE SHOW VIEW. What is the code equivalent to clicking on the Oval during the slide show that will run, for example inside an event subroutine such as PresentationNewSlide.

See attached file for the Rectangle and Oval example (you need to rename from .txt to .ppt)

Please advise

I am, dear expert, if will you allow me, to remain your faithful client,

[Or; only, if you don't wan't me as your client, please could you invite another expert to take over? However, if you do want to continue to try and help me solve this, I am okay with that.]

'The following example adds a shape to a slide, adds an animation to the shape, 
'and instructs theshape 'to begin the animation three seconds after it is clicked.
Sub AddShapeSetTiming()
    Dim effDiamond As Effect
    Dim shpRectangle As Shape
    Set shpRectangle = ActivePresentation.Slides(1).Shapes _
        .AddShape(Type:=msoShapeRectangle, Left:=100, _
        Top:=100, Width:=50, Height:=50)
    Set effDiamond = ActivePresentation.Slides(1).TimeLine.MainSequence _
        .AddEffect(Shape:=shpRectangle, effectId:=msoAnimEffectPathDiamond)
    With effDiamond.Timing
        .Duration = 5
        .TriggerType = msoAnimTriggerOnShapeClick 'Causes an error (Brian)
        .TriggerDelayTime = 3
    End With
End Sub

Open in new window

LVL 21

Expert Comment

ID: 21785680
You made me laugh.  Wasn't aware you felt the other question was being neglected, just trying to save you points.
I don't claim to be a super expert when it comes to PowerPoint VB, but I usually know enough to help.  So, to that end, take a look at:
For each interactive sequence, you designate a trigger shape; the interactive sequence starts when the user clicks that shape. To specify a trigger shape for a sequence, set the Timing.TriggerShape property of the first Effect object in the timeline of the sequence to the desired shape.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 21785723
Thanks, but no need to save me points, my points are, like American Express, unlimited.

Again, the stuff you have been pointing me to applies to setting up the animation properties.
Suppose the shapes all have the correct animation properties.
Now you go to the slide show view.
You can manually click to start whatever animation was set up.
My question is - what is the VB to do those clicks for you? (I am sooo lazy..)

PS Why is .ppt not allowed for Attach File in EE?
LVL 21

Expert Comment

ID: 21785771
Why is .ppt not allowed for Attach File in EE?  Good question, I'm assuming it's because of the malicious macro possiblity.

From: http://msdn.microsoft.com/en-us/library/aa168134(office.11).aspx

The following example adds an interactive sequence to a slide. The sequence consists of one shape that is not animated, but serves as a trigger for another shape when clicked by the user.

Dim objSequence As Sequence
Dim objShape1 As Shape
Dim objShape2 As Shape
Dim objEffect1 As Effect

With ActivePresentation.Slides(2)

    'Assign variables to shapes used in sequence
    Set objShape1 = .Shapes("Button")
    Set objShape2 = .Shapes("Arrow")
    With .TimeLine.InteractiveSequences
        'Add interactive sequence as first in collection
       Set objSequence = .Add(1)
       'Add effect for shape to fly in
       'when trigger shape is clicked
       With objSequence
        Set objEffect1 = .AddEffect(Shape:=objShape2, _
            effectId:=msoAnimEffectFly, _
        'Set trigger shape for effect
        objEffect1.Timing.TriggerShape = objShape1
       End With
    End With
End With


Author Comment

ID: 21786112
That example still ultimately requires the user to put his/er living hand (or other pointing device) onto a non-rodent mouse and squirl around until s/he gets a pointer and then move the pointer to the trigger shape (which takes a certain feat of memory and knowledge of which shape does what) and then to exert a modicum of downward pressure using one finger of that aforementioned extremity.
End Ohkayyy

So that example is another setup macro. It doesn't invoke the animation.

I am looking for a way to execute the required click equivalent via the macro.

LVL 21

Expert Comment

ID: 21787375
Ah ha.
You don't even need VBA for that, simply set the animations to start With Previous or After Previous.

Author Comment

ID: 21787613
Well. No.

Back to the original need.

I need to repeat certain sequences indefinitely within a slide (not necessarily the whole slide) and there is no apparent option to *repeat* a *sequence* of animations with with, with before or hereinafterbeforeclick or inbetweenthecracks or upsideinsidedownsideoutside. Workarounds involving cUSTOM sHOWs are nOt appropriate for my purposes.
So I conceived of having a sequence of animations triggered by an *automated* click on a hidden shape during a slide show. This invocation would be set up in an SlideShowNextSlide Event procedure and looped the required number of times.
The needed statement, (((I think, but don't know exactly, and that-is-what-I-am-asking-for-the-past-five-days))) is like the following:


May day. May day.

PS: Re: the .ppt file attachment in EE - .xls files and .doc files can have malicious macros as well, and they are allowed. So why not .ppt?
LVL 21

Expert Comment

ID: 21792787

Author Comment

ID: 21793087
So there is noone else in EE who could help?

Author Comment

ID: 24921276
This is abandoned by EE since 6/16/2008
I never got an answer

Accepted Solution

canesbr earned 0 total points
ID: 24942933
I am getting pressure to close this question

Expert Comment

by:Eric Haenke
ID: 41547588
I have a very similar need... to start the 1st animation after vba from a user form click is complete without actually clicking the slide.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
A lot of things can happen during a presentation, worst of which is “death by PowerPoint.” Here are a few mistakes to avoid to make your slides clean.
This video teaches viewers how to create handouts from their slides and helps them decide how many slides to include per handout.
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question