Application.Run method (PowerPoint)
Runs a Visual Basic procedure.
Syntax
expression.Run (MacroName, safeArrayOfParams)
expression A variable that represents an Application object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
MacroName | Required | String | The name of the procedure to be run. The string can contain the following: a loaded presentation or add-in file name followed by an exclamation point (!), a valid module name followed by a period (.), and the procedure name. For example, the following is a valid MacroName value: "MyPres.pptm!Module1.Test." |
safeArrayOfParams() | Optional | Variant | The argument to be passed to the procedure. You can specify an object for this argument. You cannot use named arguments with this method. Arguments must be passed by position. |
Return value
Variant
Example
In this example, the Main procedure defines an array and then runs the macro TestPass, passing the array as an argument.
Sub Main()
Dim x(1 To 2)
x(1) = "hi"
x(2) = 7
Application.Run "TestPass", x
End Sub
Sub TestPass(x)
MsgBox x(1)
MsgBox x(2)
End Sub
In this example, the active window is passed as an object to the procedure ShowSlideName.
Sub Main()
Application.Run "ShowSlideName", ActiveWindow.View.Slide
End Sub
Sub ShowSlideName(oSld As Slide)
MsgBox oSld.Name
End Sub
In this example, multiple arguments are passed to the procedure ShowData.
Sub Main()
Application.Run "ShowData", 100, "my text", True
End Sub
Sub ShowData(i As Integer, t As String, b As Boolean)
Debug.Print i, t, b
End Sub
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.