> AutoExec macros only execute when Word starts, and the Add-ins are
> located in the Startup folder. They do not run when loaded over the
> Addins collection.
I have to disagree with you on that, Cindy. AutoExec macros in global
templates should run when the template is loaded - no matter how, or from
where.
However, automacros do NOT run when Word is started using automation.. If
they are in Word's startup directory, though, they will be loaded so the
code as posted is unnecessary - and, as you say, Application.Run can be used
to explicitly run code.
--
Enjoy,
Tony
> > I want to run autoexec macro in addins, and call the Add method of the
> > AddIns collection. The addins are loaded, and the Installed property is
[quoted text clipped - 34 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
liu_jz@yahoo.com - 09 Mar 2006 02:43 GMT
Thanks for your help. But I have a question.
I want to run all AutoExec macro in all addins in the Startup folder. I
must know the name of the AutoExec macro if I use Application.Run. It
can be any combination of template, module, and macro name. How can I
know the name of the AutoExec macro? And what name is it if If the
addin is a .WLL file.
For example, I can write the code as follows. I must know the macro
name.
Dim gwdApp As Word.Application
Dim strFileName As String
strFileName = Dir(gwdApp.Path & "\STARTUP\")
Do While strFileName <> ""
gwdApp.Run "'" & gwdApp.Path & "\STARTUP\" & strFileName &
"'!AutoExec.Main"
strFileName = Dir
Loop
'User Profile Addins
strFileName = Dir(gwdApp.StartupPath & "")
Do While strFileName <> ""
gwdApp.Run "'" & gwdApp.StartupPath & strFileName &
"'!AutoExec.Main"
strFileName = Dir
Loop
Liu Jianzhong
Tony Jollans - 09 Mar 2006 08:33 GMT
There are reasons that AutoMacros do not run under automation and I do not
think you should just blindly be running them all. You should know what they
are doing and, if you do, you will also know what they are called - of
course it cannot be any combination of anything, automacros are identified
by their names. In a roundabout way it is possible to run them but I really
don't recommend it - do whatever you want to do explicitly.
--
Enjoy,
Tony
> Thanks for your help. But I have a question.
>
[quoted text clipped - 24 lines]
>
> Liu Jianzhong
liu_jz@yahoo.com - 10 Mar 2006 02:41 GMT
Thanks.
But I hope to get the same result as a user operating. When a user open
a document, the .dot or .wll file in the Startup folder will be loaded
automatically, and the AutoExec macro will run automatically. But open
the document by a program, these AutoExec macros can not run
automatically. I hope to get the same result using my program. Is there
any way to do this?
Liu Jianzhong
Charles Kenyon - 10 Mar 2006 05:16 GMT
Yes, when you load your Add-In programmatically, run the macros you want,
also programmatically.

Signature
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
> Thanks.
> But I hope to get the same result as a user operating. When a user open
[quoted text clipped - 5 lines]
>
> Liu Jianzhong
liu_jz@yahoo.com - 10 Mar 2006 07:35 GMT
But I do not know the AutoExec macro name. For example, it may be
"AutoExec.Main" or "ModuleName.AutoExec". I do not know the module
name. I can not run it using Application.Run.
gwdApp.Run "'" & gwdApp.StartupPath & strFileName & "'!AutoExec.Main"
or
gwdApp.Run "'" & gwdApp.StartupPath & strFileName & "'!" &
strModuleName & ".AutoExec"
Liu Jianzhong
Charles Kenyon - 10 Mar 2006 14:25 GMT
Then it can't be done.

Signature
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
> But I do not know the AutoExec macro name. For example, it may be
> "AutoExec.Main" or "ModuleName.AutoExec". I do not know the module
[quoted text clipped - 6 lines]
>
> Liu Jianzhong
Tony Jollans - 10 Mar 2006 12:43 GMT
In short, no, you cannot do this. Auto macros are disabled in applications
started via automation.
--
Enjoy,
Tony
> Thanks.
> But I hope to get the same result as a user operating. When a user open
[quoted text clipped - 5 lines]
>
> Liu Jianzhong
liu_jz@yahoo.com - 09 Mar 2006 02:43 GMT
Thanks for your help. But I have a question.
I want to run all AutoExec macro in all addins in the Startup folder. I
must knoe the name of the AutoExec macro if I use Application.Run. It
can be any combination of template, module, and macro name. How can I
know the name of the AutoExec macro? And what name is it if If the
addin is a .WLL file.
For example, I can write the code as follows. I must know the macro
name.
Dim gwdApp As Word.Application
Dim strFileName As String
strFileName = Dir(gwdApp.Path & "\STARTUP\")
Do While strFileName <> ""
gwdApp.Run "'" & gwdApp.Path & "\STARTUP\" & strFileName &
"'!AutoExec.Main"
strFileName = Dir
Loop
'User Profile Addins
strFileName = Dir(gwdApp.StartupPath & "")
Do While strFileName <> ""
gwdApp.Run "'" & gwdApp.StartupPath & strFileName &
"'!AutoExec.Main"
strFileName = Dir
Loop
Liu Jianzhong
liu_jz@yahoo.com - 09 Mar 2006 02:47 GMT
Thanks for your help. But I have a question.
I want to run all AutoExec macro in all addins in the Startup folder. I
must know the name of the AutoExec macro if I use Application.Run. It
can be any combination of template, module, and macro name. How can I
know the name of the AutoExec macro? And what name is it if If the
addin is a .WLL file.
For example, I can write the code as follows. I must know the macro
name.
Dim gwdApp As Word.Application
Dim strFileName As String
strFileName = Dir(gwdApp.Path & "\STARTUP\")
Do While strFileName <> ""
gwdApp.Run "'" & gwdApp.Path & "\STARTUP\" & strFileName &
"'!AutoExec.Main"
strFileName = Dir
Loop
'User Profile Addins
strFileName = Dir(gwdApp.StartupPath & "")
Do While strFileName <> ""
gwdApp.Run "'" & gwdApp.StartupPath & strFileName &
"'!AutoExec.Main"
strFileName = Dir
Loop
Liu Jianzhong