Prev: Find and replace text thats not wdAlignParagraphCenter alignment
Next: my footer is too big. How do I size it down?
From: TimvG on 25 May 2010 08:51 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!
From: Doug Robbins - Word MVP on 25 May 2010 16:59 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 "TimvG" <timvangelder(a)gmail.com> wrote in message news:4b625d62-495a-46f2-b614-6281f322f34f(a)n37g2000prc.googlegroups.com... > 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!
From: TimvG on 25 May 2010 18:44
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 On May 26, 6:59 am, "Doug Robbins - Word MVP" <d...(a)REMOVECAPSmvps.org> wrote: > 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 > > "TimvG" <timvangel...(a)gmail.com> wrote in message > > news:4b625d62-495a-46f2-b614-6281f322f34f(a)n37g2000prc.googlegroups.com... > > > > > 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! |