Help! Can't get macros to trigger in modules

G

Guest

I have a program(that I have no control over) that creates a word
document from a template. The template(TemplateProject) contains macros
in "ThisDocument" and a "NewMacros" Module.

The program first opens a document, with tokens like <<Name>>,
<<Company>>. Then it seems to open a new document where these values
are filled in. Then the first document is closed.

Now, my problem is that the macros in the NewMacros module is not
firing(like FileSave), but the macros in ThisDocument is firing. I
really need to get the macros in the NewModule to fire, unless if I can
somehow make the macros work from ThisDocument, but it seems like it
only has standard event triggers.

These macros works just fine when i'm opening the template myself by
clicking on it.

Thanks
 
D

Doug Robbins

What do you mean by "not firing". How are they being called? Only a macro
named Autonew() will fire automatically when a document is created from the
template.

--
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
 
G

Guest

Well, in the NewMacros module I have several events that my word
document should react to. One is FileSave(). When I click the save
button, this macro is supposed to fire, but it does not. No other event
seems to fire in this module either. As I can't seem to put this event
into ThisDocument, I need to get it to fire somehow.

If I close the newly created document and reopen it, the FileSave()
events in the NewMacros module fires. But I want it to work without
having to reopen the document as there are several other people that
are supposed to start using it.
 
G

Guest

It's weird. I can actually put FileSave() in ThisDocument and it
triggers an event, but only after I have restarted the word document.
Why would the standard events like Document_Open, Document_New etc.
trigger after first creation of the document, but not FileSave() ?

Is there a way to restart the document programmatically without the
user having to do anything?

Thanks
 
D

Doug Robbins

How about also having a macro FileSaveAs()

--
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
 
G

Guest

FileSaveAs() is not triggering either. Seems only the items under
Document, like Document_Close(), Document_New() and so on is triggering.
 
G

Guest

For some reason it seems like normal.dot becomes the active template in
the new document. Found this out my accident. I was trying to add a
buttom to the menues and saved it in my template. But when I opened the
a document on that template through the program, it used the normal.dot
template for menues.

Found a way around it though. When opening the document I added this
line in ThisDocument:
AddIns.Add FileName:="C:\MyDirectory\MyTemplate.DOT", Install:=True

That way my macros triggers.
 

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