cannot run Word macro

  • Thread starter Thread starter Cindy
  • Start date Start date
C

Cindy

I have an Access form that outputs a query to be used as a
merge data source. The Word merge doc contains a macro
called QuoteMerge. Anyone know why the following code
line returns the error "unable to run specified macro".

The actual merge document does open but the macro will not
run. If I manually run the macro in Word, it works.

'this first line of code runs fine
Set wordDoc = wordApp.Documents.Open(TEMPLATE_PATH &
SelectDoc & ".doc")

'this line of code is to invoke the macro - this is where
the error "unable to run specified macro"
wordApp.Run ("'" & TEMPLATE_PATH & SelectDoc & ".doc'!
NewMacros.QuoteMerge")

TEMPLATE_PATH = the path location
SelectDoc = the document to merge selected by the user on
the form.

Thanks.

Cindy
 
Run Method runs a Visual Basic macro

You can use
Application.Run "Normal.Module1.MAIN
Application.Run "MyProject.MyModule.MyProcedure
Application.Run "'My Document.doc'!ThisModule.ThisProcedure" If you specify the document name, your code can only run macros in documents related to the current context — not just any macro in any document

Although Visual Basic code can call a macro directly (without this method being used), this method is useful when the macro name is stored in a variable (for more information, see the example for this topic). The following statements are functionally equivalent

Normal.Module2.Macro
Call Normal.Module2.Macro
Application.Run MacroName:="Normal.Module2.Macro1"
 
that's basically what I am doing - I specify the path &
template name, module and macro name. I've used this
scenario before and it works great. Any other ideas?
-----Original Message-----
Run Method runs a Visual Basic macro.

You can use:
Application.Run "Normal.Module1.MAIN"
Application.Run "MyProject.MyModule.MyProcedure"
Application.Run "'My Document.doc'!
ThisModule.ThisProcedure" If you specify the document
name, your code can only run macros in documents related
to the current context â?" not just any macro in any
document.
Although Visual Basic code can call a macro directly
(without this method being used), this method is useful
when the macro name is stored in a variable (for more
information, see the example for this topic). The
following statements are functionally equivalent.
 
Back
Top