Help in opening powerpoint file variable from excel

M

Mithi_M

Hi all,

Was wondering if anyone could help me out. I am trying to open a new
point file or an existing powerpoint file based on a user's input from
the UserForm. Problem I am having is with the below line:

"PPApp.Presentations.Open Filename:=Enginename"

I cannot seem to open the powerpoint file using a variable name. Can
anyone help? Thanks.

Below is the full code that I have. Any help making this simple would
also be appreciated. :)


Sub ShowUserForm()

Dim Enginename As Variant
Dim Template As Variant
Dim oPPt As Object
Dim PPSlide As Object
Dim PPApp As Object
Dim PPPres As Object
Dim SlideCount As Long


PptTemplate.Show

If PptTemplate.NewPpt.Value = True Then

Set oPPt = CreateObject("PowerPoint.Application")
oPPt.Visible = True
oPPt.Presentations.Add
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation

SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
PptTemplate.Hide

ElseIf PptTemplate.TemplatePpt.Value = True Then

Enginename = PptTemplate.TemplatePpt.Value

Application.GetOpenFilename("Powerpoint Files (*.ppt), .ppt",
, "Please choose Powerpoint Template for presentation", , True) =
Enginename

If TypeName(Enginename) = "Boolean" Then
MsgBox "You have chosen to cancel the process! The application
will end. Please restart the application!", vbExclamation,
"Information"

Else
Set oPPt = CreateObject("PowerPoint.Application")
oPPt.Visible = True
Set PPApp = GetObject(, "Powerpoint.Application")
PPApp.Presentations.Open Filename:=Enginename

End If

PptTemplate.Hide

End If


End Sub
 
T

Tom Ogilvy

this line is backwards:

Application.GetOpenFilename("Powerpoint Files (*.ppt), .ppt",
, "Please choose Powerpoint Template for presentation", , True) =
Enginename


Enginename = Application.GetOpenFilename()
 

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