Solved

executing macros in view mode (powerpoint 2003)

Posted on 2010-11-10
15
542 Views
Last Modified: 2012-05-10
PowerPoint 2003 gives the opportunity of executing VBA macros when in View mode; macros can be associated to "mouseclick" or  "mouseover" events, but things don't go as they should, IMHO!
The enclosed file contains 6 macros (Macro1 to Macro6). All of them do what they are supposed to do, if executed from the immediate window of VBA (including the run-time error message issued by Macro5).
If you go into vVew mode, then only clicking on rectangle #1 you obtain a right behaviour (msgbox) while:
Clicking on rectangle 2, no messagebox is displayed
Clicking on rectangle 3, nothing is printed to the immediate window
Clicking on rectangle 3, macro execution desn't stop
Clicking on rectangle 5, no runtime error is displayed
Clicking on rectangle 6, no change in Forecolor happens
All of these behaviours mean that:
1) debugging macros in View mode is almost impossible: no STOP, no DEBUG.PRINT, no error message
2) some commands don't work at all in view mode: by ex., selecting a shape and changing one of its properties doesn't work.
DO you have any suggestion? Where to find info about what can and what cannot be done in macros executed while in View mode?
Thanks
 Presentation-1.ppt
0
Comment
Question by:blos
15 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 34100723
Hi, blos.

What do you mean by "view mode"?  Are you referring to when the presentation is running?
0
 

Author Comment

by:blos
ID: 34100760
Exactly
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 34100784
I can't make any of them work by clicking on any of the text boxes. There doesn't seem to be any link between the click event and the macro.
0
 

Author Comment

by:blos
ID: 34100877
When you open the .ppt file you need to accept macros; then pressing F5 things go as I said (with Powerpoint 2003). I verified again the exposed behaviour.
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 34100940
You have written code which cannot work in show mode but only in edit mode. Anything which relies on selection will ONLY work in edit mode. If you explain what you want to happen I will supply working code.
0
 

Author Comment

by:blos
ID: 34101112
I need to change some of the visual properties of a given shape (Forecolor, Backcolor, etc) inside a given slide of a presentation.

I would also like to be able do easily debug a macro wihich executes in show mode, and to know if an error (and which) occurs when a macro runs.
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 34103235
To change the fill of a clicked shape try

Sub changeme(oshp as shape)
oshp.Fill.Forecolor.RGB=RGB(255,0,0)
End Sub

Do you know what backcolor does, it rarely need changing unless you have a two color gradient or pattern. You could use a similar method though. If you have 2007 there's a bug in a recent update that may stop the color chamnge until you quit the show.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:blos
ID: 34104255
To say it all, what I need is :
When (in show mode) I click a given shape, a specified slide has to be shown, and a specified shape has to be highlighted; so I click on a shape (and also a slide) different from the one I want to be highlighted.
I know how to jump to a the specified slide, and also 've just found a way to change the color of the specified shape [ActivePresentation.Slides(sldID).Shapes(shpName).Fill.ForeColor.RGB = RGB(0, 0, 0)], but this isn't enough, because I would like to go back to the previous Forecolor, after having temporarily changed it in order to highlight the right shape.
Eventually I would like to change colors forth and back a few times (simulating blinking) to catch attention more effectively, or I would like to slowly rotate (360°) the right shape to attract attention...
I tried changing color forth and back inside a loop, but nothing really changes in the shape, until the loop finishes: After the loop ends, only the last color is displayed.


0
 

Author Comment

by:blos
ID: 34109463
I found a solution (inserting a DoEvents command); see the enclosed file, where clicking on box 7 (in show mode) Forecolor changes to black, and clicking on box 8 starts a 360° rotation of box 8. The solution is dirty, because rotation speed cannot be controlled, and will be different from PC to PC.

However, I still don't know where to read something about:
1) what can or cannot be done when writing macros that have to run in show mode
2) how to debug those macros, given the situation that many debugging tools (breakpoints, STOP command, DEBUG.PRINT, etc.) don't work

Any help?
Presentation-1.ppt
0
 

Author Comment

by:blos
ID: 34118216
No more hints?
0
 
LVL 23

Accepted Solution

by:
JSRWilson earned 250 total points
ID: 34134499
debug.print and STOP DO work. The first doesn't in your case because:
 You have used SELECTION which cannot work in show mode
Debug.Print ActiveWindow.Selection.ShapeRange.Fill.ForeColor.RGB
This is true of most of your code
Basically you need to rewrite most of the code avoiding selection and select
0
 

Author Comment

by:blos
ID: 34136827
I want to cancel this request, because last post of JSRWilson solves the problem, and I want to assign him his 250 points.
0
 

Author Closing Comment

by:blos
ID: 34136881
Now everything is clear! if the code contains a SELECTION, the debugging tools don't work, and no error is issued; if, instead, the code doesn't contain any SELECTION, everything works the right way, including the debugging tool. The changes I made to my code prove it.
Thanks JSRWilson!
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 34136901
Just  to be clear the debug tools work in edit mode with selection NO CODE works containing selection in show mode because it's impossible to select a shape in this mode
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can we place a tooltip on the actual vb6 form 5 35
clicking a shape in a frame array vb6 3 39
how to know if my Checkbox is True in VB6.0? 9 36
Office 2016 User Guides 5 32
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
My experience with Windows 10 over a one year period and suggestions for smooth operation
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now