PowerPoint Macros

G

Guest

I generate presentations from MSWord into powerpoint with each paragraph
creating a new slide. I require to format all the slides the same but
different from the PPT standard. I have recorded a macro which will do this
for me but I the macro recording procedure does not record the move from one
slide to the other. I ave tried both clicking on the next slide and using
the down arrow, but neither of these moves is recorded. The macro would work
beautifully for me if only I could move sequentially through the slides.

Any help would be appreciated.

Jack
 
G

Guest

Thanks for your suggestion Anne. Just tried it and it doesn't work. The
basic problem is that all the slides generated from Word have:

a) two default text boxes - the Word paragraph goes into one of these and I
have to delete one and enlarge the other
b) the wrong background and text colours - both have to be changed
c) the wrong font size - which has to be changed too.

As I said the macro works fine for the first slide but fails when it sould
move on to the next slide - back to the drawing board.

Jack
 
B

Brian Reilly, MS MVP

Jack,
The PPT recorder works some of the time, but not most of the time
without editing.

The issue here, without seeing your recorded code, always smart thing
to post here, would be that you have you have hard coded names for
shapes and slides etc, for stuff that won't work again in the run
Macro process. A long story that is covered in the PPT FAQ.

Please post a sample of the code here, nothing confidential needed,
and we can help more. And please tell us your skill level of VBA
coding (1-5) 1 being None and 5 being Expert. Don't be shy. We'll be
nice after that and even before that.

Brian Reilly, MVP
 
G

Guest

Hi Brian Many thanks for responding.

The coding copy/paste from VBA is as follows (with notes interspersed):

Sub FormatSlides()
'
' Macro recorded 31/7/2005 by Jack McLean
'
' All of this coding was generated by macro recording.

ActivePresentation.ExtraColors.Add RGB(Red:=0, Green:=102, Blue:=255)
With ActivePresentation.Slides.Range
.FollowMasterBackground = msoTrue
.DisplayMasterShapes = msoTrue
End With
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 3").Select
ActiveWindow.Selection.ShapeRange.Delete
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
With ActiveWindow.Selection.ShapeRange
.ScaleWidth 0.99, msoFalse, msoScaleFromBottomRight
.ScaleHeight 5.16, msoFalse, msoScaleFromTopLeft
End With
ActiveWindow.Selection.SlideRange.Shapes.SelectAll
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.TextRange.Font.Color.RGB = RGB(Red:=255,
Green:=255, Blue:=0)
ActiveWindow.Selection.ShapeRange.Select
ActiveWindow.Selection.Unselect

'This is where I moved down to the next slide - tried mouse select, down
arrow, page down
'each paragraph is numbered and I tried finding the next paragraph number
- the slide was slected
'but no recording was made of the find routine

ActiveWindow.Selection.SlideRange.Shapes("Rectangle 3").Select
ActiveWindow.Selection.ShapeRange.Delete
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
ActiveWindow.Selection.ShapeRange.ScaleHeight 5.03, msoFalse,
msoScaleFromTopLeft
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.TextRange.Font.Color.RGB = RGB(Red:=255,
Green:=255, Blue:=0)
ActiveWindow.Selection.ShapeRange.Select
ActiveWindow.Selection.Unselect

I am 67 years old and have been in computing (as it was in the beginning)
since 1964 as a mainframe programmer working in various assembler languages
and different manufacturer's machines, before progressing to systems
analyst/consultant/running my own software/systems house.

I am self-taught in VB but with me previous experience I can usually manage
to get round things.

Hope you can help in this - all the best.

Jack
(Computer Dinosaur)
 
B

Bill Dilworth

Hi JayMac,


I think the missing code you want looks something like this...

ActivePresentation.Slides(x).Select

....where x = slide number you want to edit

Use this to change what slide is selected


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org

PowerPoint '05 | Sep 25-28 | San Diego CA http://www.pptlive.com
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
yahoo2@ Please read the PowerPoint
yahoo. FAQ pages. They answer most
com of our questions.
www.pptfaq.com
..
..
 
S

Steve Rindsberg

Thanks for your suggestion Anne. Just tried it and it doesn't work. The
basic problem is that all the slides generated from Word have:

a) two default text boxes - the Word paragraph goes into one of these and I
have to delete one and enlarge the other
b) the wrong background and text colours - both have to be changed
c) the wrong font size - which has to be changed too.

As I said the macro works fine for the first slide but fails when it sould
move on to the next slide - back to the drawing board.

Post the macro here. It shouldn't be too hard to fix it up.

As a general rule you can do something like this:

Sub FixAllSlides()
Dim oSl as Slide

For each oSl in ActivePresentation.Slides
' Do whatever you need to do here
' When the macro runs, it'll apply the same code to each
' slide in the presentation


Next ' slide

End Sub
 
S

Steve Rindsberg

Hi Brian Many thanks for responding.

The coding copy/paste from VBA is as follows (with notes interspersed):

OK, let's try it this way, a loop through all the slides added, extraneous
MacroRecorderTrash taken out to the dumpster:

Sub FormatSlides()

Dim oSl as Slide

' set up the main loop
For each oSl in ActivePresentation.Slides
With oSl
.FollowMasterBackground = msoTrue
.DisplayMasterShapes = msoTrue
.Shapes("Rectangle 3").Delete
With .Shapes("Rectangle 2")
.ScaleWidth 0.99, msoFalse, msoScaleFromBottomRight
.ScaleHeight 5.16, msoFalse, msoScaleFromTopLeft
.TextFrame.TextRange.Font.Color.RGB=RGB(255,255,0)
End With
End With ' oSl
Next ' slide

Msgbox("Done")

End Sub
 
G

Guest

Thanks to everyone who responded to my query. I used Steve's coding as a
start point and eventuall ended up with code which worked. The only
outstanding problem now is the slide overlapst bottom and left side and has
to be manually centred. This can be done manually as the coding saves a
great deal of work.

in case anyone else has the same problem the coding is:

Sub FormatSlides()

Dim oSl As Slide


For Each oSl In ActivePresentation.Slides
With oSl
.FollowMasterBackground = msoTrue
.DisplayMasterShapes = msoTrue
.Shapes("Rectangle 3").Delete
With .Shapes("Rectangle 2").TextFrame.TextRange
.Paragraphs(Start:=1, Length:=0).ParagraphFormat.Alignment =
ppAlignCenter
.Font.Color.RGB = RGB(255, 255, 0)
.Font.Size = 40
' .Paragraphs(Start:=1, Length:=0).Select

End With
.FollowMasterBackground = msoFalse
.DisplayMasterShapes = msoTrue
With .Background
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 102, 255)
.Fill.Transparency = 0#
.Fill.Solid
End With
With .Shapes("Rectangle 2")
.ScaleWidth 1.11, msoFalse, msoScaleFromBottomRight
.ScaleHeight 5.6, msoFalse, msoScaleFromTopLeft
End With
End With
Next

MsgBox ("Done - position each slide to top left corner")

End Sub

Again thanks to everyone who responded
 
S

Steve Rindsberg

Thanks to everyone who responded to my query. I used Steve's coding as a
start point and eventuall ended up with code which worked. The only
outstanding problem now is the slide overlapst bottom and left side and has
to be manually centred. This can be done manually as the coding saves a
great deal of work.

in case anyone else has the same problem the coding is:

Glad you got it all going satisfactorily; I'm not sure quite what you mean by
the slide overlaps ... do you mean that you need to reposition the text box?

If so, modify this bit
With .Shapes("Rectangle 2")
.ScaleWidth 1.11, msoFalse, msoScaleFromBottomRight
.ScaleHeight 5.6, msoFalse, msoScaleFromTopLeft

by adding
.Left = 0 ' or however many points in from the left you want it
.Top=0 ' or however far from top
' you can also modify .Height and .Width
 
G

Guest

Thanks Steve - I searched high and low in help files and couldnt find
anything regarding positioning. Maybe I should buy a VBA manual and get down
to some real programming. But again maybe I'm too long in the tooth.

Thanks for everything - I'm indebted to you!!

Jack
 
S

Steve Rindsberg

Thanks Steve - I searched high and low in help files and couldnt find
anything regarding positioning. Maybe I should buy a VBA manual and get down
to some real programming. But again maybe I'm too long in the tooth.

Thanks for everything - I'm indebted to you!!

My pleasure, Jack. Any time
 

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