Post by Thomas LindbergDavid,
Sub ToggleVisibility()
ActiveWindow.Selection.SlideRange.Shapes("Text Box 5").Visible =
msoTriStateToggle
End Sub
The idea is that a Action button on/near an object during a slide show
shall toggle the visibility of a textbox providing help/more info for that
object .
OK, then David's nailed the problem; in slide show view, you can't select
anything, so any code that relies on any sort of selection will fail.
If you only have a few of these to do, try something like:
Sub ToggleVisibility()
ActivePresentation.Slides(42).Shapes("Text Box 5").Visible = _
Not ActivePresentation.Slides(42).Shapes("Text Box 5").Visible
End Sub
You'll have to include an edited and renamed sub for each toggle you want to
create.
If you've got a bunch to do, there's another way of doing it that's a little
more complex to understand but easier to maintain.
Sub ToggleVisibility(oSh as Shape)
Dim sShapeName as String
' What's the value of the ToggleThisShape tag?
sShapeName = oSh.Tags("ToggleThisShape")
If Len(sShapeName) > 0 Then
oSh.Parent.Shapes(sShapeName).Visible =
Not oSh.Parent.Shapes(sShapeName).Visible
End If
End Sub
To make this work, you'd need to "tag" the shape you want to toggle (do this in
edit view). Click the button shape then ctrl+click the text box. In that
order, or it won't work:
Sub TagForToggle()
Dim sToggleShapeName As String
With ActiveWindow.Selection.ShapeRange
If .Count <> 2 Then
MsgBox "Please select 2 and only 2 shapes"
Exit Sub
End If
sToggleShapeName = .Item(2).Name
With .Item(1)
Call .Tags.Add("ToggleThisShape", sToggleShapeName)
End With
End With
End Sub
Post by Thomas LindbergI am aware of what you say below, should have told the full story as per
above!
This is my first try in VBA for Ppt but I have used macros in Word and Excel
since macros and VBA was introduced,
seems to be at least one big first step to climb to use them in Ppt!
Thomas
Post by David Marcovitz(1) Action buttons only work in Slide Show View so if you are clicking
the action button in Normal view, it won't work. This doesn't seem to be
the problem as your sound plays.
(2) Many macros that work in Normal view (like when you tried to run it
from the VBA editor) won't work in Slide Show view. This is especially a
problem for macros recorded with the macro recorder. The macro recorder
likes to do things that can't be done during the slide show, like
selecting an object. Perhaps, if you post some code we could have a look.
--David
--
David Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Post by Thomas LindbergI have a macro that does what I expect when I run it from inside VBA, no
problem.
I have an Acton button that is set to run that macro when clicked: The macro
does NOT run when button clicked
Changing the action to Play sound works OK, sound played when button
clicked
File saved as .pptm in Ppt2007 and as .ppt in Ppt2003
Realize that there is a setting somewhere to enable the macro to run but I
can't find it.
A humble request for HELP!!
Thomas