Reputation: 1437
I have a powerpoint file with the following macro:
Sub test(msg$)
MsgBox msg
End Sub
I have a vbscript file that looks like this:
Option Explicit
On Error Resume Next
RunMacro
Sub RunMacro()
Set ppApp = CreateObject("Powerpoint.Application")
Set ppPres = ppApp.Presentations.Open("test.pptm", 1)
ppApp.Run "test.pptm!test ""my message here"" "
ppApp.Quit
Set ppPres = Nothing
Set ppApp = Nothing
End Sub
But I can't seem to pass the string parameter to the macro (no message box shows up in PPT). I'm guessing something is wrong with the number of quotation marks, but I've tried every permutation I could think of and nothing works. If I hard-code the message in the macro everything works fine.
Related (tried these, with no luck)
How to call Run() with parameters
Upvotes: 0
Views: 150
Reputation: 200293
When in doubt, read the documentation. You're confusing the (VBScript) WshShell.Run
method with the (VBA) Application.Run
method.
Change this:
ppApp.Run "test.pptm!test ""my message here"" "
into this:
ppApp.Run "test.pptm!test", "my message here"
Upvotes: 2