slide numbering in macros

G

Guest

why will the following maco stop working when i get to slide 10? slides 1-9
work perfect but as soon as i edit and change to slide 10 and above it stops?

Code working:

ActivePresentation.Slides(9).Shapes("AutoShape 2") _
.TextFrame.TextRange.Text = "X"
ActivePresentation.Slides(9).Shapes("AutoShape 2") _
.TextFrame.TextRange.Font.Color = vbYellow
ActivePresentation.Slides(9).Shapes("AutoShape 2") _
.TextFrame.TextRange.Font.Size = 96

SlideShowWindows(1).View.GotoSlide 167
Code NOT working:

ActivePresentation.Slides(10).Shapes("AutoShape 2") _
.TextFrame.TextRange.Text = "X"
ActivePresentation.Slides(10).Shapes("AutoShape 2") _
.TextFrame.TextRange.Font.Color = vbYellow
ActivePresentation.Slides(10).Shapes("AutoShape 2") _
.TextFrame.TextRange.Font.Size = 96

SlideShowWindows(1).View.GotoSlide 178

Do i have to do something with the numbering after you get to double figures?

many thanks

Glyn Jones

PS Many thanks to Bill, John & David for getting me this far
 
G

Guest

Yes I do, Its the same as slide 1-9 but when you press the button it takes
you to another slide and puts an X on the button to say you have pressed it.
 
B

Bill Foley

Not sure the problem, but this is the format of code I use to go to a
particular slide:

ActivePresentation.SlideShowWindow.View.GotoSlide (3)
 
G

Guest

Its not the goto section that is the problem its the first line where the
code reads:

ActivePresentation.Slides(9).Shapes("AutoShape 2") _

the number in the brackets after Slides is the only major change to the
code. It all works fine with single numbers but as soon as I put double
figures in it stops working
 
D

David M. Marcovitz

The double-digits shouldn't make any difference at all. That is why Shyam
suggested that something might be different with the slides. Try this:

Go to slide 9 and insert a duplicate slide so that slide 10 is EXACTLY
the same as slide 9. Then try your code on slide 10.

--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/
 
S

Steve Rindsberg

Glyn Jones said:
why will the following maco stop working when i get to slide 10? slides 1-9
work perfect but as soon as i edit and change to slide 10 and above it stops?

Code working:

Try it this way:

Dim oSh as Shape
On Error Resume Next
' Change the 9 to 10 etc as needed
Set oSh = ActivePresentation.Slides(9).Shapes("AutoShape 2")
If oSh Is Nothing Then
MsgBox "Yo, Glyn! There's no AutoShape 2 on this slide"
Exit Sub
End If

With oSh.TextFrame.TextRange
.Text = "X"
.Font.Color = vbYellow
.Font.Size = 96
End With

' change the GoToSlide number as needed
SlideShowWindows(1).View.GotoSlide 167
 

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