Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / May 2008

Tip: Looking for answers? Try searching our database.

VBA: Slow execution working with shape visibility

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin Dufendach - 26 May 2008 17:17 GMT
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 - 26 May 2008 18:11 GMT
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
Signature

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

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

> Using VBA to change properties (visibility, text, transparency) of a shape on
> a slide with many others runs slowly.
[quoted text clipped - 37 lines]
> End Sub
> ''''''''''''''''''''''''''''''
Kevin Dufendach - 26 May 2008 19:22 GMT
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).
John Wilson - 27 May 2008 08:57 GMT
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?
Signature

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

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

> 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).
Kevin Dufendach - 27 May 2008 17:24 GMT
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 - 27 May 2008 21:37 GMT
You might want to check out Shyam's tutorial about how to use VBA with
animations:

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

Signature

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

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

> I'll bet your suspicion is correct, that PPT is taking time to redraw
> the slide.  Unfortuantely, the hardware acceleration option didn't
[quoted text clipped - 8 lines]
> figure out how to advance an interactive sequence.  Do you have any
> idea how to advance an interactive sequence using VBA?
Kevin Dufendach - 27 May 2008 22:04 GMT
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 - 28 May 2008 21:51 GMT
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

> 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).
Kevin Dufendach - 29 May 2008 15:04 GMT
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.:

-----------------------------------------------------------
|                                                          |
|                                                          |
[quoted text clipped - 3 lines]
|                                                          |
|   [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.
Austin Myers - 26 May 2008 19:24 GMT
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

> Using VBA to change properties (visibility, text, transparency) of a shape
> on
[quoted text clipped - 39 lines]
> End Sub
> ''''''''''''''''''''''''''''''
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.