Syntax for PowerPoint VBA to invoke a Trigger

Posted on 2008-06-12
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.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.


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.


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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

829 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