Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: 8 Mar 2006 00:40:13 -0800,    group: microsoft.public.word.vba.addins        back       


How to run autoexec macro in addins programmatically   
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
True. But the autoexec macro in the addins is not run.
Why? How to run autoexec macro in addins programmatically?

I write the code as follows:


Dim gwdApp As Word.Application
Dim strFileName As String

strFileName = Dir(gwdApp.Path & "\STARTUP\")
Do While strFileName <> ""
    gwdApp.AddIns.Add gwdApp.Path & "\STARTUP\" & strFileName, True
    strFileName = Dir
Loop
'User Profile Addins
strFileName = Dir(gwdApp.StartupPath & "")
Do While strFileName <> ""
    gwdApp.AddIns.Add gwdApp.StartupPath & "\" & strFileName, True
    strFileName = Dir
Loop



Liu Jianzhong
date: 8 Mar 2006 00:40:13 -0800   author:   unknown

Re: How to run autoexec macro in addins programmatically   
> 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
> True. But the autoexec macro in the addins is not run.
> Why? How to run autoexec macro in addins programmatically?
>  
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. Nor should you store Addins you intend to load as you 
show in your code in the Startup folder; they should be in a different 
folder.

You can try to use the Application.Run method to run macros in loaded 
Addins.

> I write the code as follows:
>  
>  
> Dim gwdApp As Word.Application
> Dim strFileName As String
>  
> strFileName = Dir(gwdApp.Path & "\STARTUP\")
> Do While strFileName <> ""
>     gwdApp.AddIns.Add gwdApp.Path & "\STARTUP\" & strFileName, True
>     strFileName = Dir
> Loop
> 'User Profile Addins
> strFileName = Dir(gwdApp.StartupPath & "")
> Do While strFileName <> ""
>     gwdApp.AddIns.Add gwdApp.StartupPath & "\" & strFileName, True
>     strFileName = Dir
> Loop
>

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or 
reply in the newsgroup and not by e-mail :-)
date: Wed, 08 Mar 2006 17:46:54 +0100   author:   Cindy M -WordMVP-

Re: How to run autoexec macro in addins programmatically   
> 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


"Cindy M -WordMVP-"  wrote in message
news:VA.0000bb54.005596b4@speedy...
> > 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
> > True. But the autoexec macro in the addins is not run.
> > Why? How to run autoexec macro in addins programmatically?
> >
> 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. Nor should you store Addins you intend to load as you
> show in your code in the Startup folder; they should be in a different
> folder.
>
> You can try to use the Application.Run method to run macros in loaded
> Addins.
>
> > I write the code as follows:
> >
> >
> > Dim gwdApp As Word.Application
> > Dim strFileName As String
> >
> > strFileName = Dir(gwdApp.Path & "\STARTUP\")
> > Do While strFileName <> ""
> >     gwdApp.AddIns.Add gwdApp.Path & "\STARTUP\" & strFileName, True
> >     strFileName = Dir
> > Loop
> > 'User Profile Addins
> > strFileName = Dir(gwdApp.StartupPath & "")
> > Do While strFileName <> ""
> >     gwdApp.AddIns.Add gwdApp.StartupPath & "\" & strFileName, True
> >     strFileName = Dir
> > Loop
> >
>
> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
> http://www.word.mvps.org
>
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
>
date: Wed, 8 Mar 2006 18:39:03 -0000   author:   Tony Jollans My Forename at My Surname dot com

Re: How to run autoexec macro in addins programmatically   
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
date: 8 Mar 2006 18:43:03 -0800   author:   unknown

Re: How to run autoexec macro in addins programmatically   
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
date: 8 Mar 2006 18:43:33 -0800   author:   unknown

Re: How to run autoexec macro in addins programmatically   
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
date: 8 Mar 2006 18:47:06 -0800   author:   unknown

Re: How to run autoexec macro in addins programmatically   
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


 wrote in message
news:1141872183.821727.37370@i39g2000cwa.googlegroups.com...
> 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
>
date: Thu, 9 Mar 2006 08:33:24 -0000   author:   Tony Jollans My Forename at My Surname dot com

Re: How to run autoexec macro in addins programmatically   
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
date: 9 Mar 2006 18:41:39 -0800   author:   unknown

Re: How to run autoexec macro in addins programmatically   
Yes, when you load your Add-In programmatically, run the macros you want, 
also programmatically.
-- 
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.


 wrote in message 
news:1141958499.319423.144180@j52g2000cwj.googlegroups.com...
> 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
>
date: Thu, 9 Mar 2006 23:16:14 -0600   author:   Charles Kenyon

Re: How to run autoexec macro in addins programmatically   
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
date: 9 Mar 2006 23:35:55 -0800   author:   unknown

Re: How to run autoexec macro in addins programmatically   
In short, no, you cannot do this. Auto macros are disabled in applications
started via automation.

--
Enjoy,
Tony


 wrote in message
news:1141958499.319423.144180@j52g2000cwj.googlegroups.com...
> 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
>
date: Fri, 10 Mar 2006 12:43:39 -0000   author:   Tony Jollans My Forename at My Surname dot com

Re: How to run autoexec macro in addins programmatically   
Then it can't be done.
-- 
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.


 wrote in message 
news:1141976155.616932.192100@j52g2000cwj.googlegroups.com...
> 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
>
date: Fri, 10 Mar 2006 08:25:18 -0600   author:   Charles Kenyon

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us