View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Excel Macro call Word Macro with Parameters

Bill,

Strings must be wrapped in double quotes, not single:

wordApp.Run ("myMacro", "String with spaces", numVal1, numVal2)

and your macro in the word document must be properly declared, along the lines of:

Sub myMacro(myStr As String, myVal1 As Double, myVal2 As Double)

HTH,
Bernie
MS Excel MVP

"Bill Sturdevant" wrote in message
...
I have a macro in Excel that calls a macro in a Word document with this code:

wordApp.Visible = True
wordApp.Activate
wordApp.Run ("myMacro")

But when I changed the Word macro to require parameters, using the following
code, I get Run-time error '-2147352573 (80020003)' Unable to run the
specified macro:

wordApp.Visible = True
wordApp.Activate
wordApp.Run ("myMacro", 'String with spaces', numVal1, numVal2)

So I tried using the following code, but I get Object doesn't support this
property or method:

wordApp.Visible = True
wordApp.Activate
result = wordApp.Run ("myMacro", 'String with spaces', numVal1,
numVal2)

What code should I be using?