Consulting

Results 1 to 6 of 6

Thread: PowerPoint VBA - Animation Help

  1. #1
    VBAX Regular
    Joined
    May 2011
    Posts
    14
    Location

    PowerPoint VBA - Animation Help

    Hi to All,

    First time user of this Forum, Hopefully I can get some help on this.

    THE REQUIREMENT:
    I have a PowerPoint page with 4 squares (from autoshapes). Each square has some text in it which I have set to appear one after the other in each of the boxes upon mouse click using custom animation tools.

    Once the text appears, I have an Action Setting on each box for a MACRO to run on each of the boxes upon click of the box. The Macro (in VBA seen below) is expected to change the color of the box to orange first. If the box selected is the correct one, the color of that box changes to green. If the box selected is incorrect, the color of the correct box should turn green.

    THE ISSUE:
    The Problem I am facing is that since I am bringing in the text into the boxes VIA custom Animation, when the Macro runs on the box, the color changes correctly, but the text in all the boxes disappears.
    If however, I do not use custom Animation to bring in the text, everything works as it is suppposed to. But my requirements is to being in the text into the boxes one by one.

    SAMPLE CODE FOR THE COLOR CHANGE:

    Sub SelectAnswer1(shpA As Shape)
    Dim shp2 As Shape
    Dim ss As Slide

    shpA.Fill.ForeColor.RGB = RGB(255, 165, 0)
    For Each ss In ActivePresentation.Slides
    For Each shpA In ss.Shapes
    If shpA.HasTextFrame Then
    If StrComp(shpA.TextFrame.TextRange, "Text1", vbTextCompare) = 0 Then
    shpA.Fill.ForeColor.RGB = RGB(124, 242, 0)
    For Each shp2 In ss.Shapes
    If shp2.Fill.ForeColor.RGB = RGB(255, 165, 0) Then
    y = Timer + 0.1
    Do While Timer < y
    DoEvents
    Loop
    End
    End If
    Next shp2
    End If
    End If
    Next shpA
    Next ss
    End Sub

    Any help will be greatly appreciated.

    Thanks

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    It works here. What version of PPT is this? Is there a reason why you loop through all the slides instead of the shapes on the currect slide?

    Changing shapes with vba often resets the animation sequence and I guess this is what is happening. Not easy to fix! Maybe have the animations on one slide and then auto move to a duplicat with no animations?
    Last edited by John Wilson; 05-16-2011 at 12:17 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Also you may be able to do this without vba using triggers?
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  4. #4
    VBAX Regular
    Joined
    May 2011
    Posts
    14
    Location
    I am using PPT 2003.

    The reason why I am checking all slides is because I intend to have more code where I do string comparisons for blocks on other slides. Rather than having a seperate macro for each slide, I'd rather have one macro and check in all slides for the different strings of text that I am looking for.

    Now coming back to your answer, you mention that it works for you?

    Would you mind explaining to me how you go about setting your autoshapes and your strings in the shapes. May be I am missing a step here.

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    I was using 2010, in 2003 I'm pretty sure the code would reset the animations back and lose the text.

    There is no need to check all slides though to avoid just using one code module simply set ss to SlideShowWindows(1).View.Slide and it will reference the current slide.

    You can download a code free solution here otherwise I would look at the duplicate slide method which is slides 2 & 3

    Never going to be perfect in all versions though.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  6. #6
    VBAX Regular
    Joined
    May 2011
    Posts
    14
    Location
    I will try the same out on 2010. Other than that, thanks for the NO CODE reference.

    Really appreciate your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •