Below is a demonstration of using PowerPoint.Application to open a PowerPoint file and then run a macro that is stored within the PowerPoint file.

  1. Make sure you modify “fullpath\p1.pptm” and point it to the full path-filename to your PowerPoint file.
  2. Modify the macro name. Macro name must be full macro name with file, module and macro name in your PowerPoint file in order for this script to work. Use the following format “p1.pptm!Module1.name”
Sub RunPowerPointMacro()

Dim objPP As Object
Dim objPPFile As Object

Set objPP = CreateObject("PowerPoint.Application")
objPP.Visible = True

Set objPPFile = objPP.Presentations.Open("fullpath\p1.pptm")

Application.EnableEvents = False

objPP.Run "p1.pptm!Module1.name"

Application.EnableEvents = True

objPPFile.Close

Set objPPFile = Nothing
Set objPP = Nothing

End Sub

 

Posted by Excel Instructor:

https://www.chicagocomputerclasses.com/excel-classes/