Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a PowerPoint Macro

Status
Not open for further replies.

dlingo

Programmer
Nov 19, 2001
60
0
0
US
I'm attempting to launch Microsoft PowerPoint, open a presentation, and then run a macro contained within the presentation. However, the following code isn't working properly. Any help is much appreciated.

Sub Main
Dim filename = "filename"
Dim macroname = "macroname"
Call OpenFile
End Sub

Function OpenFile(filename, macroname)
Dim pptApp As PowerPoint.Application
Set pptApp = New PowerPoint.Application
pptApp.Visible = True
Dim pptPres As PowerPoint.Presentation
Set pptPres = pptApp.Presentations.Open(filename, msoCTrue)
pptApp.WindowState = ppWindowMaximized

'The following line generates the error.
pptApp.run(macroname)
End Function

Thank you in advance.
 
How are you compiling this:
Code:
Dim filename = "filename"
Dim macroname = "macroname"
Seems like it should read:
Code:
Sub Main()
  Dim filename As String
  Dim macroname As String
 
  filename = "C:\Presentations\myFile.ppt"
  macroname = "myMacro"

  Call OpenFile(filename, macroname)
End Sub
VBSlammer
redinvader3walking.gif
 
How did I miss that simple mistake? I'm sure that's my problem. I will retry the declaration tomorrow at work. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top