My macro don't "refresh" SlideMaster? / código VBA no actualiza objetos...

A

Antonio

Hello,
can anyone help me?
In my macro in PowerPoint 97 (Windows 2000), I change some controls of slide
master from visibles to invisibles and viceversa, in order to show them in
the next slide or not.
....
SlideMaster.OptionButton1.Visible = False
....
SlideShowWindows(1).View.GotoSlide (n)
....

But sometimes, the change don't work (the control remains visible) unless I
stop the slide show (and then, the control appears invisible).
How I can to solve this? How I can "refresh" the slide master?

Thanks in advance

Antonio

---------------------

Hola a todos.

He hecho una macro en PowerPoint 97 (Win 2000) que pongo en un botón de la
diapositiva patrón; al pulsarlo, hace visibles o invisibles algunos
controles de esa misma diapositiva patrón y muestra la siguiente diapositiva
en pantalla; así consigo que funcionen esos botones en las diapositivas que
quiero, sin tener que poner esos botones en todas las diapositivas.

Pero muchas veces, si por ejemplo le he dicho que oculte un botón y muestre
la diapositiva siguiente:
....
SlideMaster.OptionButton1.Visible = False
....
SlideShowWindows(1).View.GotoSlide (n)
....

no me hace caso y el botón se ve; sin embargo, si paro la presentación, el
botón es invisible (incluso si en el código le digo que me diga el estado de
ese botón, me dice que es invisible).

¿A qué puede ser debido? ¿acaso hay que refrescar de algún modo la
diapositiva patrón?

En PowerPoint 2002 funciona sin apenas problemas, pero la presentación
deberá verse en equipos con el 97, y los visores de PowerPoint parece que
avisan que no funcionan bien con macros.

Muchas gracias por anticipado.

Antonio
 
S

Shyam Pillai

Antonio,
Try calling this routine everytime you hide/unhide the shape.

Sub RefreshSlide()
Dim lSlideIndex As Long
lSlideIndex = SlideShowWindows(1).View.CurrentShowPosition
SlideShowWindows(1).View.GotoSlide lSlideIndex
End Sub
 
A

Antonio

Thank you, Shyam, but don't work :-(

Even if I make many "GotoSlide" in order to refresh my slide, the invisible
control appears visible :-(

Best regards,

Antonio
 
B

Bill Dilworth

You'll love this.

I do not know if PP97 is the exact same (perhaps someone will test this on
other operating systems) but what you stated holds true for PPXP as well.

When you make the command button non-visible, what you continue to see on
the screen is NOT the command button, but the image rendered by PowerPoint
as the background image based on the master slide as it was constructed for
that slide. So when the button disappears, then image of the button (as
part of the overall background) continues to show thru.

To fix this, reverse your thinking. Instead of trying to hide the button on
some slides, make it appear on the others. Insert the button on the Master
Slide. Make it non-visible. Now, when called to be rendered, the
background image will show thru the button space. If the button is made
visible, it will appear in front of the background. Keep in mind that you
will need to make the button non-visible PRIOR to the next slide's
rendering, or you will be right back where you started.

Steve, do I get the useless tricks award for this one?


--
Bill Dilworth, Microsoft PPT MVP
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
B

Bill Dilworth

I did some more checking into this and, guess what: I was wrong. Call it
my tenacity to find the root case of a problem, or just plain stubborness,
but I was troubled by this all day while I was't near a computer. Only when
I started to play with it did I discover my incorrect assumptions.

PowerPoint does more then just create an image of the command button in the
background image, it reserves the space and stays active, even when the
visible property is set to false. In fact, if you move the command button,
the original placement stays visible and active and the new location only
gets a picture of the button. But all this strange behaivior only happens
if the button was visible when the slide was rendered.

If the button is not visible when the slide was rendered, then the button
can be make visible, made invisible again, or even moved anywhere on the
slide, but will not act as a command button, ever.

Therefore, in order to get the command button to appear (and disappear) and
work as expected, you will need to force the presentation to redraw the
slide afer adjusting the command button. This is best done by inserting a
blank slide with a zero second transition before the target slide and
telling the sub to link to that slide, forcing the re-rendering of the
slide.


My recommendation, use a shape and make it look like a button. Assign it an
Action Setting to run whichever Sub routine will make you happy. You'll
sleep better. It will do what you want and not go rouge, like those wild
buttons do. Shapes do expected things in pretty much expected ways, buttons
don't seem to follow the same rules.

Bill Dilworth
 
B

Bill Dilworth

Correct, CommandButtons are easily replaced. But some of the other control
objects cab be useful. They all follow this strange behavior pattern.

Affects:
CommandButton
CheckBox
TextBox
OptionButton
ListBox
ComboBox
ToggleButton
Labels
ImageBox
Scrollbar
SpinButton

Basically, all the control objects. I'll email you a write up on it next
week.

Bill Dilworth
 
Top