Running a macro in PowerPoint via Excel?

T

Toby Erkson

I have Excel 2002 running and want to RUN a macro contained in PowerPoint
2002 (OS is XP). My VBA is limited and the examples I've found aren't
helpful. Here is something I tried, trouble is, PowerPoint has to be
already launched and I don't want to do that if possible. Suggestions?
TIA!
-----
Private Sub Workbook_Open()
' Executing a PowerPoint macro...the indirect way.
Dim PPT As Object

Set PPT = CreateObject("PowerPoint.Application") 'Creates the object
pptDir = "C:\Projects\Automate\" '*
pptFileName = "Daily Orders Dashboard-test.ppt" '*
pptPath = pptDir & pptFileName
PPT.Presentations.Open pptPath, , , False 'Loads the already existing
(specific) object

TheMacroToExecute = "Main" '*
pptMacroPath = pptFileName & "!Module1." & TheMacroToExecute
PPT.Run pptMacroPath 'This snazzy command executes the macro

'Macro is done so quit PPT
PPT.Quit 'Exit the object
Set PPT = Nothing 'Destroy the object (free up memory)

Application.Quit 'Exit Excel
End Sub
-----
 
T

Tom Ogilvy

You won't be able to run a powerpoint macro unless powerpoint is up and
running. The powerpoint executable is the only software that can interpret
and act on the macro commands.
 

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