Run macro from button in slideshow

B

Blaine76

Is it posible to insert a button in powerpoint and have a macro
attached to it so that when you run the slideshow you can click on the
button to run the macro. I have tryed this but I keep getting an error
to the effect of "no active page selected".

Even if I dont run the macro from the slide show it would be great but
when Im in design view the buttons arent clickable

Thanks
 
D

David M. Marcovitz

Buttons are only clickable in Slide Show View. You can run macros in
Design View by choosing Tools > Macro > Macros. Is the error your getting
an error that the code is generating?
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
B

Blaine76

This is the code im using

Sub load()
'
' Macro created 6/2/2005 by Blaine Polley
'
Dim strPath As String
Dim strFileSpec As String
Dim oPic As Shape


' Edit these to suit:
strPath = "c:\temp\"
'strFileSpec = "browning.bmp"

strFileSpec = InputBox("What is the name of the file?")
With ActiveWindow.View.Slide.Shapes
Set oPic = .AddPicture(FileName:=strPath & strFileSpec, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=10, _
Top:=20, _
Width:=150, _
Height:=100)
End With


End Sub

But when I run it in the slide show it gives me the error " There is no
current active window document"?
 
S

Steve Rindsberg

Blaine76 said:
Is it posible to insert a button in powerpoint and have a macro
attached to it so that when you run the slideshow you can click on the
button to run the macro. I have tryed this but I keep getting an error
to the effect of "no active page selected".

It's already working. That is, your macro is running but it needs a bit of
rewrite to get it to work during a slide show (where you can't select anything)
vs in design mode.

Post your code and we can help fixemup.
 
G

Guest

Aha! Now I see. You have a macro that was designed to run in Design View, and
you are running it in Slide Show View. Try changing:

With ActiveWindow.View.Slide.Shapes

to

With ActivePresentation.SlideShowWindow.View.Slide.Shapes

That should work for you (except I'm writing this wihthout testing it so I
might have screwed something up).

--David

David Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
B

Blaine76

David, Your the man

Thanks that worked for me great.

Thanks for everyones time.

Blaine
 
E

eldon.l.lehman

Blaine76 said:
Is it posible to insert a button in powerpoint and have a macro
attached to it so that when you run the slideshow you can click on the
button to run the macro. I have tryed this but I keep getting an error
to the effect of "no active page selected".

Even if I dont run the macro from the slide show it would be great but
when Im in design view the buttons arent clickable

Thanks
Blaine,
After you have done the things that David and Steve have mentioned, a
bit of code may be useful in future macro builds.
From Shyam's website:
http://skp.mvps.org/ppt00040.htm#2

Determine which shape was clicked (PowerPoint only)
begin code -------------
Sub Identify(oShp as Shape)
Msgbox oShp.Name, vbInformation+vbOkOnly
End Sub
end code ---------------

This has saved me many lines of code that would invariably get tangled
in a wicked weave. You can assign this to any shape on the slide. It
will determine which shape was clicked and you can write decision
making programs for it.

Eldon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top