How to tell Word where to find a Macro...

T

TimvG

I'm trying to find some programmatic (VBA) way to tell Word that it
should look in a particular place to find a macro.

Here's the context of the problem. I have a macrobutton field, and
the macro name is Toggle. The Toggle macro lives in the Toggling
module in an add-in, i.e. a template in the Startup folder. Under
normal circumstances, clicking the macrobutton fires the Toggle macro
in the template. No worries.

Now, the user is creating a document with toggling functionality and
wants to send that document to somebody else who doesn't have the
template installed. So, they can click a button to copy the bare
minimum required macros from the template into the document. This
works fine, but now if you click on the macrobutton (while still on
the computer which has the add-in installed) the macrobutton fires the
Toggle macro in the document, not in the template.

Suppose now user thinks "oh no, I don't want to send a macro-loaded
document to my colleagues; I'll strip out the macros." I've provided
a button for them to do this; it just deletes the Toggling module, and
everything in it, from the document.

And this is where the problem arises. If the user now tries clicking
on the macrobutton field, nothing happens. Word thinks the Toggle
macro is in the document, but it has vanished from there. Word
doesn't know that the original Toggle macro is still in the add-in
template.

The problem can be fixed by closing and re-opening the document. But
I don't want to make my users close and re-open. Rather I want a
behind-the-scenes way to make Word do what it did originally, i.e.
find the Toggle macro in the template.

I feel sure there must be a command for this, or an easy fix, but
haven't been able to find it.

Any pointers much appreciated!

- Tim
 

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