Make OnAction refer to a macro in a specific file

S

src

I'm having the same problem as Richard below.

I have a sub that creates a list of boilerplate documents from
filenames in a folder. The Onaction calls another sub that creates a
new document and inserts the boilerplate in it.

The problem is that the Onaction only runs properly when the document
with the macro is the active document. Since that document is a
global addin, I'd like to be able to run the macro from ANY document
that's open.

I too am having trouble finding out:
A) Is it possible to run Onaction macros from other documents, and if
so

B) What is the best syntax to put in the Onaction statement?

Word 2003 on WinXP Pro SP2.

Thanks!
- - - - - - - - - - - - - - -

1. richardcranfordnospam View profile
More options Mar 17 2003, 2:28 pm

I'm working on a prototype for a Word application that
will generate boilerplate letters. The application adds an
option to the menu when it's opened. When you select the
new menu option, then a suboption, the macro opens a new
file and writes a letter. The addition to the menu stays
in place, but it ceases to work unless the document
containing my macros is in the active window. I think what
I want is to have the OnAction statement refer explicitly
to the macro, including the file name, but I'm having
trouble finding the right syntax for that. Any ideas?

TIA

--Richard
 
S

src

After a few hours poring over these posts, I stumbled across a fix:

If you use just the macroname, the macro will only run if the calling
document is based on the template that contains the menubar (i.e. my
global addin).
OnAction = "mymacro"

*** To allow the macro to be run from any open document:
OnAction = "mymodule.mymacro"

If you use the full macro location, it throws a "macro not found"
error:
OnAction = "myproject.mymodule.mymacro"

Don't ask me why...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top