Mystery of the Invisible Macros

T

TimvG

I have a document (.dotm) with a code module, Toggling, with macros in
the module. However Word doesn't seem to know that the macros are
there.

When I try to fire one of the macros, using a Macrobutton field,
nothing at all happens.

When I open the Macro dialog (Alt-F8) no macros from that file show up
(though other macros are visible). When I open the Organizer, the
module Toggling is visible in Macro Project Items for the document.

When I open the Visual Basic Editor, open Toggling and run a macro
from there (F5), the macro works fine.

When I create a new macro outside Toggling, it works fine. But when I
copy it into Toggling, it is no longer accessible.

It seems that Word knows that the code module is there, but doesn't
know that the macros are inside it.

The only probably-important clue I can think of is that the Toggling
module was created in the document by importing it from a file using
ActiveDocument.VBProject.VBComponents.Import

Any suggestions most appreciated!
 
D

Doug Robbins - Word MVP

Insert a new module into the template and copy and paste the code from the
Toggling module into that.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
T

TimvG

Thanks Doug. Unfortunately I don't think I can use that approach, at
least via manual copy and paste, because I need to do this
programmatically.

(The context is: I'm developing a Word template which must put Macros
into documents which are released to a wider world of users who will
not have the template.)

However your suggestion did help me stumble upon an apparent
solution. If, after loading up the Toggling module into the document,
I then (programmatically) simply rename the module, suddenly Word
discovers that there are macros in it!

This seems to work for me now - though I'm always a bit uncomfortable
adopting a "solution" when I don't really understand why I had the
problem in the first place.

Cheers

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