Is This Content Helpful?
We're glad to know this article was helpful.
The VBA sample in this article demonstrates how to run and pass arguments to a macro using the IVbaApplication::RunVBAMacro command. The arguments are passed using a Variant array.
Dim pVbaApp As IVbaApplication
Set pVbaApp = Application
Dim myArray As Variant
'enter name and age
myArray = Array("Jane Doe", 34)
pVbaApp.RunVBAMacro "Project", "Module1", "MyMacro", myArray
Sub MyMacro(Name As String, Age As Integer)
MsgBox "Your name is " & Name & " and you are " & Age & " years old."