Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Defining PowerPoint template in VBA-code

Status
Not open for further replies.

Pohohanheim

Technical User
May 26, 2005
6
EE
Hello!

I have a small problem concerning PowerPoint. I've created a handy macro which creates a PP-slide show based on information on an Excel file. The problem is that I don't know how to define the template PP uses in VB-code. That "blanco" template isn't suitable for my purposes. So, is there any way to change template via macro?
 
You may consider the ApplyTemplate method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I tried that Apply Template method but all I get is an error message: "Run-time error '492' ActiveX component can't create object" Am I missing a reference??
 
Why not posting the relevant code ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OK, here it goes..

Sub PP()

Const ppLayoutTitle As Integer = 1
Const ppLayoutText As Integer = 2
Const ppLayoutTitleOnly As Integer = 11
Const ppEffectFlyFromTop As Integer = 3330
Const ppEffectBoxIn As Integer = 3074
Const ppSlideShowUseSlideTimings As Integer = 2
Const ppEffectRandom As Integer = 513
Const ppWindowMaximized As Integer = 3
Const ppEffectCheckerboardDown As Integer = 1026
Const ppAdvanceOnTime As Integer = 2
Const ppAnimateByWord As Integer = 1
Const ppAnimateByFirstLevel As Integer = 1
Const ppEffectBoxOut As Integer = 3073



Dim Pres1 As Object
Dim Slide1 As Object
Dim Shape1 As Object
Dim Shape2 As Object
Dim Shape3 As Object
Dim Shape4 As Object
Dim Shape5 As Object
Dim Picture1 As Object
Dim SlideNum As Integer
Dim x As Variant

tehdas = Sheets("Lib").Range("L2")




Set PPTApp = CreateObject("PowerPoint.Application")
ActivePresentation.ApplyTemplate "C:\Documents and Settings\kaikkoa\Application Data\Microsoft\Templates\Templates\EasyDOC(FinINTL)\A4p_customer.pot"


With PPTApp
.Visible = True
.WindowState = ppWindowMaximized
Set Pres1 = PPTApp.Presentations.Add

End With


Set Slide1 = Pres1.Slides.Add(1, ppLayoutTitleOnly)
With Slide1
With .Shapes(1)
.Top = 120
With .TextFrame.TextRange
.Text = "Hedging levels for " & tehdas & Chr(13) & _
"2007-2010"
.Font.Size = 54
End With

End With
End With


x = 0
For x = 0 To 2

SlideNum = Pres1.Slides.Count + 1
Set Slide1 = Pres1.Slides.Add(SlideNum, ppLayoutTitleOnly)
PPTApp.ActiveWindow.View.GotoSlide SlideNum

Next



Sheets("Main page").ChartObjects("Chart 10").CopyPicture
With PPTApp.ActivePresentation.Slides(2).Shapes
With .PasteSpecial(DataType:=ppPasteMetafilePicture, Link:=False, DisplayAsIcon:=False)
.Height = 1350
.Width = 625
.Left = 50
.Top = 110

End With
End With



Sheets("2007").Range("A1:O38").Copy
With PPTApp.ActivePresentation.Slides(3).Shapes
With .PasteSpecial(DataType:=ppPasteMetafilePicture, Link:=False, DisplayAsIcon:=False)
.Height = 1350
.Width = 625
.Left = 50
.Top = 110

End With
End With



End Sub
 
Perhaps this ?
Set PPTApp = CreateObject("PowerPoint.Application")
With PPTApp
.Visible = True
.WindowState = ppWindowMaximized
Set Pres1 = .Presentations.Add
End With
Pres1.ApplyTemplate "C:\Documents and Settings\kaikkoa\Application Data\Microsoft\Templates\Templates\EasyDOC(FinINTL)\A4p_customer.pot"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top