Creating a master slide using vba

S

Silvester

Hi,

Í'd like to create a PP2000 master slide on the fly using vba. I've created
a PP macro and but I'm not able to translate the ActivePresentation and
ActiveWindow into the vba code. Basically I would like to create a simple
master slide that will have a color scheme, a logotext textbox and a main
textbox. My problem is that I cannot figure out how to replace PP code
ActiveWindow in the VBA code. I want to be able to replicate the PP macro
code below in VBA code.

'PP macro
If ActivePresentation.HasTitleMaster Then
ActivePresentation.TitleMaster.ColorScheme =
ActivePresentation.ColorSchemes(Index:=1)
End If
ActivePresentation.SlideMaster.ColorScheme =
ActivePresentation.ColorSchemes(Index:=1)
ActivePresentation.Slides.Range.ColorScheme =
ActivePresentation.SlideMaster.ColorScheme

ActivePresentation.SlideMaster.Shapes.AddLabel(msoTextOrientationHorizontal,
510, 485, 200, 36#).Select
ActiveWindow.Selection.ShapeRange.TextFrame.WordWrap = msoFalse

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With ActiveWindow.Selection.TextRange
.Text = "Logotext"
With .Font
.Name = "Times New Roman"
.Size = 24
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppForeground
End With
End With

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=8).Select
ActiveWindow.Selection.TextRange.Font.Name = "Arial Black"

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=8).Select
ActiveWindow.Selection.TextRange.Font.Italic = msoTrue

ActivePresentation.SlideMaster.Shapes.AddTextbox(msoTextOrientationHorizonta
l, 54#, 48#, 612#, 36#).Select
ActiveWindow.Selection.ShapeRange.TextFrame.WordWrap = msoTrue

ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With ActiveWindow.Selection.TextRange
.Text = "text here"
With .Font
.Name = "Times New Roman"
.Size = 24
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppForeground
End With
End With
End Sub


Here is the VBA code so far

'Create a new presentation in PowerPoint
Dim oPPT As PowerPoint.Application
Dim oPres As PowerPoint.Presentation
Set oPPT = New PowerPoint.Application
Set oPres = oPPT.Presentations.Add(True)

oPres.Slides.Add 1, ppLayoutBlank

With oPres.SlideMaster.ColorScheme
.Colors(SchemeColor:=ppBackground).RGB = RGB(Red:=51, Green:=102,
Blue:=153)
.Colors(SchemeColor:=ppForeground).RGB = RGB(Red:=255, Green:=255,
Blue:=0)
.Colors(SchemeColor:=ppShadow).RGB = RGB(Red:=128, Green:=128,
Blue:=128)
.Colors(SchemeColor:=ppTitle).RGB = RGB(Red:=0, Green:=0, Blue:=0)
.Colors(SchemeColor:=ppFill).RGB = RGB(Red:=0, Green:=204,
Blue:=153)
.Colors(SchemeColor:=ppAccent1).RGB = RGB(Red:=51, Green:=51,
Blue:=204)
.Colors(SchemeColor:=ppAccent2).RGB = RGB(Red:=204, Green:=204,
Blue:=255)
.Colors(SchemeColor:=ppAccent3).RGB = RGB(Red:=178, Green:=178,
Blue:=178)
End With

If I am able to successfully creat a slide master on the fly, then I assume
that any slide I insert after that will follow the slidemaster, right ?

Thanks for any help.
 
S

Shyam Pillai

Silvester,
Grab a reference to the added shape and then use that reference:

Dim oShp as Shape
Set
oShp=ActivePresentation.SlideMaster.Shapes.AddLabel(msoTextOrientationHorizo
ntal,510, 485, 200, 36#)
oShp.TextFrame.WordWrap = msoFalse
' - - - - - - -
 

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