Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA: Slow execution working with shape visibility

564 views
Skip to first unread message

Dufendach@discussions.microsoft.com Kevin Dufendach

unread,
May 26, 2008, 12:17:01 PM5/26/08
to
Using VBA to change properties (visibility, text, transparency) of a shape on
a slide with many others runs slowly.

I have a slide with a shape set to run the following code (below) which
toggles the visibility of another shape and toggles a document tag.
Everything works as expected, but the update takes about 0.5 seconds (on a
Centrino Duo 1.66 GHz).

I believe the slow execution has to do with the number of other shapes on
the slide (about 70). If I create a new first slide and copy the over to it,
it runs almost instantaneously. If I then add several shapes to that new
slide, it again runs slowly. I've tried referencing the object directly
(.Slides(1).Shapes(56).Fill.Visible = msoTrue), but that doesn't seem to
change anything. Does anyone know if there is a better way for me to be
referencing shapes or changing properties to speed things up?

Thanks so much!
Kevin

'''''''''''''''''''''''''
Sub ToggleShow1()

On Error GoTo OnError

With ActivePresentation
Select Case .Tags("Show1")
Case "False"
.Tags.Add "Show1", "True"
.Slides(1).Shapes("Check1").Fill.Visible = msoTrue
Case Else
.Tags.Add "Show1", "False"
.Slides(1).Shapes("Check1").Fill.Visible = msoFalse
End Select
End With

NoErrors:
Exit Sub

OnError:
End Sub
''''''''''''''''''''''''''''''

John Wilson

unread,
May 26, 2008, 1:11:01 PM5/26/08
to
Hi Kevin

I'm not sure this would run much faster but could you not do away with the
tegs and use this to toggle

With ActivePresentation.Slides(1).Shapes("Check1")
.Fill.Visible = Not .Fill.Visible
End With
--
-------------------------------------------
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk

Kevin Dufendach

unread,
May 26, 2008, 2:22:58 PM5/26/08
to
I get the same slow result with the ".fill.visible =
not .fill.visible" command. I wonder if I could use animation appear/
disappear to change this. Unfortunately, I don't know how to use VBA
to trigger an animation item, and I still need to use VBA since I need
to change the tag (I reference it in a different macro later. This is
a toggle box for options for a different macro).

Austin Myers

unread,
May 26, 2008, 2:24:30 PM5/26/08
to
Kevin,

You might try naming the shapes instead of using a number. When you use the
number the code has to count (enumerate) each shape on the slide (to make
certain there are 56 of them (or whatever number your after.) I've found
executing code on a named shape is almost instant.

Austin Myers
Microsoft PowerPoint MVP Team

Creator of PFCPro, PFCMedia and PFCExpress
http://www.playsforcertain.com

"Kevin Dufendach" <Kevin Dufe...@discussions.microsoft.com> wrote in
message news:AF01FE19-84AE-4C56...@microsoft.com...

John Wilson

unread,
May 27, 2008, 3:57:01 AM5/27/08
to
Hi Kevin

I suspect the time lag is PowerPoint redrawing the slide (and the 70
objects). Try ticking hardware accelleration in Slide Show > Set up show.
Does that help at all?


--
-------------------------------------------
Amazing PPT Hints, Tips and Tutorials

Kevin Dufendach

unread,
May 27, 2008, 12:24:09 PM5/27/08
to
I'll bet your suspicion is correct, that PPT is taking time to redraw
the slide. Unfortuantely, the hardware acceleration option didn't
help anything. I think the best option would be to step away from the
".Fill.Visible" property and use an "appear" animation, as that works
just fine even with many objects on the same slide. I was thinking I
could set the figure to appear with click on a trigger and also to
disappear with a trigger, and then I could use VBA to activate the
Appear or Disappear effect based on what the "Check1" tag value is.
Using "activepresentation.SlideShowWindow.View.Next," I can advance
the next animation in the main timeline, but unfortunately, I can't
figure out how to advance an interactive sequence. Do you have any
idea how to advance an interactive sequence using VBA?

David M. Marcovitz

unread,
May 27, 2008, 4:37:13 PM5/27/08
to
You might want to check out Shyam's tutorial about how to use VBA with
animations:

http://skp.mvps.org/ppttimeline1.htm

--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

Kevin Dufendach <krd.p...@gmail.com> wrote in news:f750dcde-8baa-4324-
99b6-bf9...@d1g2000hsg.googlegroups.com:

Kevin Dufendach

unread,
May 27, 2008, 5:04:34 PM5/27/08
to
Thanks for the suggestion, David. Shyam always has great stuff, and
this tutorial is no exception. Unfortunately, it doesn't yet answer
my question as to how to advance an InteractiveSequence animation
(page still under construction).

Shyam Pillai

unread,
May 28, 2008, 4:51:04 PM5/28/08
to
Kevin,
Firing a trigger sequence by code isn't supported natively. You could send a
mouse-click message to the shape under the current cursor position but it's
too klunky for a general solution.

Is this code running in slide show mode or design mode?

Regards,
Shyam Pillai

Image Importer Wizard
http://skp.mvps.org/iiw.htm

"Kevin Dufendach" <krd.p...@gmail.com> wrote in message
news:6b05d2cc-65f1-4f8c...@t54g2000hsg.googlegroups.com...

Kevin Dufendach

unread,
May 29, 2008, 10:04:12 AM5/29/08
to
Thanks Shyam,

I'm sorry to hear that you can't control trigger sequences (at least,
not easily). I'm running this in slide show mode. Basically, this is
a checkbox that sets an option that the rest of the presentation will
reference. e.g.:

-----------------------------------------------------------
| |
| |
| Whales |
| by Kevin Dufendach |
| |
| |
| [X] go to random [ Go! ] |
-----------------------------------------------------------

When the user checks the "Go to random" checkbox, then every time
[ Go! ] is pressed, a random slide is brought up. When it's not
checked, then the [ Go! ] button just goes to the next slide (the
[ Go! ] button is part of the master, so it's repeated on every
slide). The program should also remember what the state of the
checkbox is so that the next time the presentation is run, it will
remember the user's preference and have that automatically set.

Thanks, all, for your suggestions.

0 new messages