How do I open a Powerpoint document in Excel VBA ?

Hi All,

I'm trying to open a Powerpoint document within my Excel VBA code but I keep getting the following error message:

'Object doesn't support this property or method'

My code looks like this:

   Dim PowerpointApp As Object
   Dim PowerpointDoc As Object
   Set PowerpointApp = CreateObject("Powerpoint.Application")
   Set PowerpointDoc = PowerpointApp.Documents.Open(gcCertificateTemplatePath)
   PowerpointApp.Visible = True

Open in new window


It falls over at the open of the document. However, the PPT document does actually exist. Could the issue lie in my previous line ?

I have set the relevant reference, Microsoft Powerpoint 14.0 Object Library

Thanks
Toco
TocogroupAsked:
Who is Participating?
 
Jamie GarrochPowerPoint Consultant & DeveloperCommented:
Make sure that the app is visible before you do anything with it and use the Open method for the app's Presentations collection e.g:

Dim PPTApp As Object
Dim PPTPres As Object
Set PPTApp = CreateObject("PowerPoint.Application") 
PPTApp.Visible = True 
Set PPTPres = PPTApp.Presentations.Open(gcCertificateTemplatePath) 

Open in new window

0
 
TocogroupAuthor Commented:
Thanks Jamie. That was the exact solution. Much appreciate your assistance.
Regards
Toco
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.