Hi,

I am looking for a way to run a "Sub AutoExec" on loading the template
that contains the macro (by checking a template in the Tools > Templates
and Add-ins dialog box OR by placing the template in the Startup folder
of Word).

How can this be done?

Re: Run autoexec macro on loading a template? by Jonathan

Jonathan
Thu Feb 19 05:35:47 CST 2004

Hi and

If you place the sub in a standard module, and ensure it has no arguments,
then it will run automatically when the template is loaded as an add-in,
provided that the macro security settings in Word permit the code to run

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup


"and" <and@nospam.invalid> wrote in message
news:403486fa$0$1197$fb624cd1@morenews.zeelandnet.nl...
> Hi,
>
> I am looking for a way to run a "Sub AutoExec" on loading the template
> that contains the macro (by checking a template in the Tools > Templates
> and Add-ins dialog box OR by placing the template in the Startup folder
> of Word).
>
> How can this be done?


Re: Run autoexec macro on loading a template? by Peter

Peter
Thu Feb 19 05:49:04 CST 2004

Hi and

I think you've just said it all, you create a sub called AutoExec! Actually
there are two ways of doing it:

- Create a sub called AutoExec: "Public Sub AutoExec()". This must be in a
module not a UserForm or a class.
- Create a Module called "AutoExec" anad a sub named Main:
"Public Sub Main()"

Place either one of these procedures (macros) in your template and it will
execute when the Add-In loads. That's either when Word starts (if it's in one
of Words startup folders) or when you load the Add-In.

HTH + Cheers - Peter



and <and@nospam.invalid> wrote in news:403486fa$0$1197$fb624cd1
@morenews.zeelandnet.nl:

> Hi,
>
> I am looking for a way to run a "Sub AutoExec" on loading the template
> that contains the macro (by checking a template in the Tools > Templates
> and Add-ins dialog box OR by placing the template in the Startup folder
> of Word).
>
> How can this be done?
>


Re: Run autoexec macro on loading a template? - THANKS by and

and
Thu Feb 19 06:17:05 CST 2004

Thanks Peter and Jonathan,

It didn't work because I had the template simply opened as a file to
edit the vba code, but when I closed the template and loaded it manually
by checking it in the dialog box, it worked alright.



-------- Original Message --------


> Hi and
>
> I think you've just said it all, you create a sub called AutoExec! Actually
> there are two ways of doing it:
>
> - Create a sub called AutoExec: "Public Sub AutoExec()". This must be in a
> module not a UserForm or a class.
> - Create a Module called "AutoExec" anad a sub named Main:
> "Public Sub Main()"
>
> Place either one of these procedures (macros) in your template and it will
> execute when the Add-In loads. That's either when Word starts (if it's in one
> of Words startup folders) or when you load the Add-In.
>
> HTH + Cheers - Peter
>
>
>
> and <and@nospam.invalid> wrote in news:403486fa$0$1197$fb624cd1
> @morenews.zeelandnet.nl:
>
>> Hi,
>>
>> I am looking for a way to run a "Sub AutoExec" on loading the template
>> that contains the macro (by checking a template in the Tools > Templates
>> and Add-ins dialog box OR by placing the template in the Startup folder
>> of Word).
>>
>> How can this be done?
>>
>

Re: Run autoexec macro on loading a template? by Graham

Graham
Thu Feb 19 06:42:22 CST 2004

An autoexec macro works exactly as you describe ie if the containing
template is located in the Word or Office startup folder it will run when
the template is loaded, when Word is started.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail gmayor@mvps.org
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>


and wrote:
> Hi,
>
> I am looking for a way to run a "Sub AutoExec" on loading the template
> that contains the macro (by checking a template in the Tools >
> Templates and Add-ins dialog box OR by placing the template in the
> Startup folder of Word).
>
> How can this be done?