kenmck
asked on
How do I run a Word Macro From VB?
I have a Word template with a macro. This macro makes the report and sends it to the printer.
Does anyone know a way from VB that I can open this template and run the macro automatically?
Does anyone know a way from VB that I can open this template and run the macro automatically?
Call your macro "Auto_open", everytime the user loads the template macro is executed.
Cheers
Cheers
Sorry, call your macro like this (from whitin your template):
Private Sub Document_New()
Call Auto_Open ' Or whatever you name your macro
End Sub
Private Sub Document_New()
Call Auto_Open ' Or whatever you name your macro
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers that worked fine.
Thanks for your help.
Thanks for your help.
Just a question:
If that worked fine, why a "B" grade?
Glad to help you.
Cheers.
If that worked fine, why a "B" grade?
Glad to help you.
Cheers.
ASKER
I have the problem of having to make VB wait till Word has opened before it can pass the variables. It works fine but will be better I am assured when using .net.
Cheers
Cheers
Make sure you reference the microsoft word object library. Then, using your word object you can use the wdObject.Documents.Add("C:
Then, you can use wdObject.Run MacroName:="TheMacroThatDo
If you have instantiated word and it's standing by with the template open that has the macro, it should run fine.
Grtz.©
D.