Run Macro during slide show

G

Guest

Hi
I am having trouble assigning a macro to an action button to work during a
show. I have read a lot of the previous answers but I still can't get it to
work.
I am running a small quiz where the front sheet has ten buttons numbered 1
to 10, when you click on a button it takes you to a set slide with a question
on, at the bottom of that page is another button that takes you back to the
selection slide. What I am trying to do is when you press the numbered button
a large X apears on the button to say that that button has been used. This is
the macro that I have written and it works ok in edit mode but will not work
in slide show format.

ActiveWindow.Selection.SlideRange.Shapes("AutoShape 7").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=1).Select
ActiveWindow.Selection.TextRange.Text = "X"
ActiveWindow.View.GotoSlide Index:=2
End Sub

Any help would be appriciated

Glyn
 
B

Bill Dilworth

Hi Glyn,

This is the key aspect you seem to have missed. You can not select anything
in a slideshow, only while in edit view. Therefore, macros recorded in edit
view will not play in edit view if they rely on selections.

Instead of this (I assume you are trying to change the text in the shape to
"X")...
---------
ActiveWindow.Selection.SlideRange.Shapes("AutoShape 7").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange _
.Characters(Start:=1, Length:=1).Select
ActiveWindow.Selection.TextRange.Text = "X"
ActiveWindow.View.GotoSlide Index:=2
End Sub
----------

Try this ....
---------
ActivePresentation.Slides(1).Shapes("AutoShape 7") _
.TextFrame.TextRange.Text = "X"
SlideShowWindows(1).View.GotoSlide 2
End Sub
---------

--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
G

Guest

Hi Bill

Thanks very much this now seems to work. one other question is how would
you change the "X" to be larger and red in colour?

Thanks Glyn
 
G

Guest

Rather than specifying a specific shape I'd try this

Sub redx(oshp As Shape)
If oshp.HasTextFrame Then
With oshp.TextFrame.TextRange
..Text = "X"
..Font.Color = vbRed
..Font.Size = 24
End With
End If
SlideShowWindows(1).View.GotoSlide 2
End Sub
--
Did that answer the question / help?
___________________
John Wilson
Microsoft Certified Office Specialist
http://www.technologytrish.co.uk/ppttipshome.html
email john AT technologytrish.co.uk
 
G

Guest

Hi John

thanks for your suggestion, I tried your script but it did not work so i
tried to combine bills code that does work with what i thought would change
the X but failed. here is the code I came up with but i get a compile erroe:
invalid or unqualified reference on the first .font.color=vbred

ActivePresentation.Slides(1).Shapes("AutoShape 7") _
.TextFrame.TextRange.Text = "X"
.Font.Color = vbRed
.Font.Size = 24
SlideShowWindows(1).View.GotoSlide 2
End Sub

many thanks

Glyn
 
D

David M. Marcovitz

Try this:

Sub ChangeToX()
With ActivePresentation.Slides(1).Shapes("AutoShape 7") _
.TextFrame.TextRange
.Text = "X"
.Font.Color = vbRed
.Font.Size = 24
End With
SlideShowWindows(1).View.GotoSlide 2
End Sub

The With means that for the next few lines assume everything starting
with a dot starts with ActivePresentation.Slides(1).Shapes("AutoShape
7").TextFrame.TextRange

You also might want to check out my site which has lots of examples of
quizzes in PowerPoint, not specifically what you are doing, but it will
give you lots of ideas:

http://www.PowerfulPowerPoint.com/

--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.PowerfulPowerPoint.com/
 
G

Guest

Hi Glyn

David's code should work fine but only for "autoshape 7". I thought you had
a range of shapes. My code above will work with any shape you click as long
as it has an action "play macro" and a text frame. If your shapes have no
text just right click and "add text" (no actual text needed)

If stuck email me a slide and I'll have a look.
-- email john AT technologytrish.co.uk
Did that answer the question / help?
___________________
John Wilson
Microsoft Certified Office Specialist
http://www.technologytrish.co.uk/ppttipshome.html
 

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