0

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

Shell.Run with arguments

1

1 Answer 1

2

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"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.