Discussion:
action button to start a macro???
(too old to reply)
Thomas Lindberg
2008-12-03 14:59:56 UTC
Permalink
Ppt2003 and Ppt2007, same problem:

I 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
David Marcovitz
2008-12-03 15:57:19 UTC
Permalink
There are a few things that could be a problem:

(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 Lindberg
I 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
Thomas Lindberg
2008-12-04 07:27:05 UTC
Permalink
David,

Here is the macro:

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 .

I 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 Lindberg
I 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
David Marcovitz
2008-12-04 15:56:41 UTC
Permalink
OK. Now we are getting somewhere. Macros in PowerPoint are much
different than macros in Word and Excel, partly because PowerPoint has
to deal with Normal view and Slide Show view. Anything with "Selection"
or "Select" in the macro will not work in Slide Show View. Try this
instead:

ActivePresentation.SlideShowWindow.View.Slide.Shapes("Text Box
5").Visible = msoTriStateToggle

Everthing in that line up to (but not including) the .Shapes is just a
fancy way to refer to the current slide in Slide Show View.
Alternatively, you could specify the exact slide:

ActivePresentation.Slides(3).Shapes("Text Box 5").Visible =
msoTriStateToggle

That will work for Slide 3 no matter what the current slide is.

--David
--
David Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Post by Thomas Lindberg
David,
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 .
I 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 Lindberg
I 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
Steve Rindsberg
2008-12-04 17:28:21 UTC
Permalink
Post by Thomas Lindberg
David,
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 Lindberg
I 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 Lindberg
I 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
Thomas Lindberg
2008-12-05 08:18:45 UTC
Permalink
Thanks to David for nailing my problem and to Steven for the continuation I
have in mind but not tried because of the base problem!!


Thomas
Post by Steve Rindsberg
Post by Thomas Lindberg
David,
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.
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
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 Lindberg
I 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 Lindberg
I 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
Loading...