AutoExec not firing in Global template

D

DataDay

I am starting Word from an external application and it is intentionally not
visible, but the code in the AutoExec sub of one of my global startup
templates is not firing. How can I make it fire?

Thanks
 
J

Jonathan West

I suspect the problem is that you have Word set as the Outlook email editor,
and you have an email editing window open when you start Word proper.

The only workaround I know of is for any of the macros called by toolbar
buttons or menu items you have with your addin to check whether AutoExec has
already run (the AutoExec routine can set a flag to indicate it has run),
and to run it if it hasn't already.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
D

DataDay

Hello Jonathan,

Thanks for responding. Actually we are not using Word as out email editor.

I'll investigate the toolbar option you mention.

Please let me know if you think of any other reasons why this may be
happening.

Thanks
 
T

Tony Jollans

I think this is by design. AutoExec macros are suppressed when Word is
started via Automation.
 
M

Marc Adams [marcmyword.com]

Perhaps you can have your external application call your autoexec code. You
will need a public handle to the code, but that's pretty simple. It should be
relatively straightforward to do so.

something like (very rough)
dim appWord as word.application
appWord.getobject() [again no thought with this, I'm assuming you have a
handle already]
appWord.Application.Run "publicroutinethatcallsautoexec"

Maybe that may work.
 
T

Tony Jollans

AutoOpen macros are not suppressed by Automation, that is true,

But .. AutoOpen macros don't fire in global templates (they are not
'opened')
 
D

DataDay

Tony, you are so right.

Marc, I went with your solution and it seems to be working, I've got to test
it a little more, but that seems to be the ticket.

Thank you both so much.
 

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