[RESOLVED] Trigger Macro from add in (vs 2003)
Hello!
I have an add-in (written in vs 2003) that changes the default template (normal.dot) to a custom one (start.dot) when Word starts. The problem is that the macro in start.dot isnt triggered. Is there a way to force it to trigger?
code:
doc.AttachedTemplate = strPath
thanx!
/Dave
Re: Trigger Macro from add in (vs 2003)
it should work if you put your code in document new event in thisdocument code pane
Re: Trigger Macro from add in (vs 2003)
I change the template in the WindowActivate event. When I start Word, the template has changed, but the macro isn't running. Isn´t there something similar to RunAutoMacro but for custom macros?
Code:
Public Sub act(ByVal doc As Word.Document, ByVal wn As Word.Window) Handles appWord.WindowActivate
doc.AttachedTemplate = strPath
End Sub
Re: Trigger Macro from add in (vs 2003)
I solved it!
I took a closer look at the macro, and it was triggered at the event Document_New(). So i used the doc.RunAutoMacro(Word.WdAutoMacros.wdAutoNew) to force the Document_New() function to run.
Thanks for your help! It got me thinking in new directions. The code is now:
Code:
Public Sub act(ByVal doc As Word.Document, ByVal wn As Word.Window) Handles appWord.WindowActivate
doc.AttachedTemplate = strPath
doc.RunAutoMacro(Word.WdAutoMacros.wdAutoNew)
End If
Re: Trigger Macro from add in (vs 2003)
if you declare application with events in your addin, all application events can have code