vba code create a new powerpoint presentation

diana
3StarLounger
Posts: 279
Joined: 01 Jun 2010, 00:27

vba code create a new powerpoint presentation

Post by diana »

VBA how do I create a new powerpoint presentation from a powerpoint template and leave on screen


Im using the following code

However the result is
launches a new presentation but then displays the Save screen

If I click No
the result is no presentation open

see screen captures

dd

>>>>>

code

Sub main()


On Error GoTo Err_PPT

Dim oPA As PowerPoint.Application
Dim oPP As PowerPoint.Presentation
Dim sPath As String
Dim sFile As String


sPath = "C:\Program Files\CorrsOffice\Templates\"
'template
sFile = "Trout.potx"
'presentation
'sFile = "Trout.pptx"


Set oPA = New PowerPoint.Application
oPA.Visible = msoTrue

Set oPP = oPA.Presentations.Add(msoTrue)


If Not oPS Is Nothing Then Set oPS = Nothing
If Not oPP Is Nothing Then Set oPP = Nothing
If Not oPA Is Nothing Then Set oPA = Nothing



Err_PPT:
If Err <> 0 Then
MsgBox Err.Description
Err.Clear
Resume Next
End If
You do not have the required permissions to view the files attached to this post.

diana
3StarLounger
Posts: 279
Joined: 01 Jun 2010, 00:27

Re: vba code create a new powerpoint presentation

Post by diana »

Resolved.

i ditched the above previous code.

heres the code I wrote to get it working... yay! :cheers:

Sub main()

Dim oPA As PowerPoint.Application
Dim oPP As PowerPoint.Presentation
Dim strTemplate As String

strTemplate = "C:\Program Files\CorrsOffice\Templates\Trout.potx"

Set oPA = New PowerPoint.Application
oPA.Visible = msoTrue
oPA.Presentations.Open strTemplate, untitled:=msoTrue


End sub

User avatar
StuartR
Administrator
Posts: 12618
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: vba code create a new powerpoint presentation

Post by StuartR »

Thanks for sharing your solution.
StuartR