Calling Next Slide Error

J

jonathan

Im using PP 2000.

I have a PPT that has several slides and I tried recording
a macro. The macro is supposed to record all the titles
that I type on each of the slides. Each slide is supposed
to have a different title.

In the generated macro, "Rectangle 2" is the title
object(if this is what VBA calls it since im new to this).

When I run my macro, PP just puts all the titles in the
first slide. I think the macro didnt understand that it
was the next slides that should have the title since they
all have the same title object.

How can I tell the macro, that the next text title is for
the next slides title?
 
S

Shyam Pillai

Jonathan,
Please post the recorded macro code. It would be easier to correct it and
explain the reasons for the failure.
 
J

jonathan

Here is my recorded macro for 3 slides.
I typed on the titles of each slide and got this macro, but
when I run the macro. It justs wrote all the text on the
first slide.

ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With ActiveWindow.Selection.TextRange
.Text = "slide title 1"
With .Font
.Name = "Times New Roman"
.Size = 44
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppTitle
End With
End With
ActiveWindow.Selection.Unselect
ActiveWindow.Selection.SlideRange.Shapes("Rectangle
2").Select

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With ActiveWindow.Selection.TextRange
.Text = "slide title 2"
With .Font
.Name = "Times New Roman"
.Size = 44
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppTitle
End With
End With
ActiveWindow.Selection.Unselect
ActiveWindow.Selection.SlideRange.Shapes("Rectangle
2").Select

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With ActiveWindow.Selection.TextRange
.Text = "slide title 3"
With .Font
.Name = "Times New Roman"
.Size = 44
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppTitle
End With
End With
ActiveWindow.Selection.Unselect
 
J

jonathan

And I think, I usually get an error on this part.
It seems like the "Rectangle 2" changes from slides, but I
checked it already and the object name is the same.
I got something working here, but on a top-to-bottom run,
it encounters an error. However, if i run it step-by-step,
if works fine.

ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
 
D

David M. Marcovitz

Why don't you try the following. It will change the text of Rectangle 2
on three slides. Just repeat the pairs of lines and change Slides(3) to
Slides(4), Slides(5), etc. to change the text on more slides. Does this
do what you want to do, or I am missing something? By the way, this has
no error-checking so you have to be sure you have all the slides that you
want to change the title for, and you have to be sure they all have title
areas. Shyam (who is a far better programmer than I) will probably post
complete code with error checking later, but this is the quick and dirty
way to do what I think you want to do.

Sub AddTitles()
ActivePresentation.Slides(1).Shapes("Rectangle 2") _
.TextFrame.TextRange.Text = "slide title 1"
ActivePresentation.Slides(2).Shapes("Rectangle 2") _
.TextFrame.TextRange.Text = "slide title 2"
ActivePresentation.Slides(3).Shapes("Rectangle 2") _
.TextFrame.TextRange.Text = "slide title 3"
End Sub

--David

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

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