Run Module at Startup

J

Jonathan West

Hi vTown

Yes. Give the macro you want to run on startup the name AutoExec.
 
J

Jezebel

If the module is called AutoExec, Word will run Sub Main() in it at
start-up. I think Excel is similar but the module must be called Auto_Exec.
 
V

Vtown

Thanks, I tried AutoExec and it seems to be
created in the Normal.dot so when it runs
the bookmarks for my specific document aren't
found. Naming the module Auto.Exec with Sub
Main() in the doc( not in the normal) doesn't
seem to run. Any suggestions on running this
outside of the normal and in this particular doc?
 
J

Jonathan West

Hio vTown,

For a template which is loaded as an add-in, an AutoExec macro in that
template is automatcially run when the add-in is loaded. If the add-in is in
Word's startup folder, then it is loaded automatically on startup and
AutoExec runs at that time.

An AutoExec macro in a template attached to a document does not run
automatically.
 
V

Vtown

I appreciate it Jonathan. What exactly is an Add-In
and how would a template(my document?) be loaded and
placed in the startup folder?
 
J

JGM

H Vtown,

I think that if you want meanigful tips, you are going to explain in more
details what it is you are trying to achieve.

You asked about executing macros as Word/Excel starts up, got an answer,
then from your reply to that first answer, I got the distinct feeling that
actually you need to know how to execute a procedure when a particuplar
document is opened... and I fail to see the connection to Excel...

???

Cheers!
 
M

Malcolm Smith

A startup template is different from a document template (which is
something which you are perhaps used to) in that no document is based upon
it at all.

A start-up template contains nothing but code, toolbars and the like and
lives in the user's start-up folder. To see what is your start-up folder
go and look in Tools | Options | File Locations.

What happens is, as the name suggests, is that when the application such
as Word starts all the code in the start-up folder is loaded. And this
code can be called from any other template or it can be called by people
clicking on new toolbars or the code can be called by having the events of
Word trapped.

The best thing to do is to have a look at some examples. On my site there
are few examples of .dot files which can be placed into the start-up
folder. Go and do this and then get an idea of what can be done.

Examples include:
http://www.dragondrop.com/WordCoding/word004.asp
http://www.dragondrop.com/WordCoding/word009.asp


Have a look at the code and get to play with it for a while and then you
may have a better idea as to what a start-up folder is and how it can be
used.

I really must improve this part of the site sometime...

- Malc
www.dragondrop.com
 
J

Jonathan West

Vtown said:
I appreciate it Jonathan. What exactly is an Add-In
and how would a template(my document?) be loaded and
placed in the startup folder?

If you go to Tools, Options and click the File Loacations tab, you will be
able to see the location of a number of special folders. One of these is the
startup folder.

A template stored in that folder is automatically loaded as an add-in when
Word starts. Its macros are available for use from all documents, just like
those of normal.dot, and its AutoExec macro runs when the template is
loaded.

You can see whatadd-ins are loaded if you go to Tools, Templates and Addins.

This article describes more about add-ins.

What do Templates and Add-ins store?
http://www.mvps.org/word/FAQs/Customization/WhatTemplatesStore.htm

This article also provides useful information

Distributing macros to other users
http://www.mvps.org/word/FAQs/MacrosVBA/DistributeMacros.htm
 
V

Vtown

JGM,

The tips provided were very meaningful, in fact. I needed
info on Word AND Excel, if available, and the questions
I asked resulted in relevant and adequate answers.
Expressing your 'distinct feeling' and mentioning
your 'failure to see a connection' regarding my replies is
absolutely a pointless waste of time.
 
J

JGM

"Vtown" <[email protected]> a écrit dans le message de
[email protected]...
JGM,

Sorry to have ruffled your feathers...
The tips provided were very meaningful, in fact. I needed

I never wrote that the tips you had received were not meaningful. I have
read hundreds of posts written by the other three people that gave you
advice, and I know that they know what they are talking about and that they
are very knowledgeable. I guess I should have written "if you want MORE
meaning ful tips..." (Meaning "advice that is more meanigful to your
context," not "a greater quantity of meaningful advice.")
info on Word AND Excel, if available, and the questions
I asked resulted in relevant and adequate answers.
Expressing your 'distinct feeling' and mentioning
your 'failure to see a connection' regarding my replies is

Sorry to disagree, but again, I have seen hundreds of cases where the people
giving the advice actually wasted their valuable time because of a lack of
understanding of the problem or a lack of clarity in exposing the problem. I
just thought that yours might have been one of those, and since I was
willing to use my time too actually give you advice ( I may not be as
professional as some of the other posters, but in this particluar case, I
could have given very adequate advice), I just wanted to make sure that I
was going to write something that was relevant tou your situation.
Obviously, my choice of words has insulted you, so I am taking notice of
this and will remember next time to use very bland and neutral words.

Sorry I could not read between the lines... But when someone talks about
running a macro when Word or Excel is launched:

and then goes on to explain that something is not working because

it is clear to me that this person needs advice.

But then I ask myslef:
How can I help? Running macros as an app starts is slightly different
between Word and Excel I have done both and just wanted to make sure that
any comments I might provide were useful. Also, the autoexec is executed
only once, when the App is started, so unless the app is started every
single time by double clicking on a particular document (while no other
instance of Word are running) then the said bookmarks are not going to be
found. And if the code needs to be run when the said document containing the
bookmarks is opened, we are not talking about an autoexec anymore...
Before giving any advice, I just would like to clear up the issues.

Again, sorry if I have offended you, but as you can see, I wrote what I did
because I cared and wanted to help, not to bother or demean you.
I you feel my asking for more information in order to give you advice
tailored to your situation is
absolutely a pointless waste of time.

Then I am sorry you feel that way.
Someone who cares, who has received loads of advice from these groups and
who wants to return the favor whenever possible.

Cheers.
 
V

Vtown

Monsieur JGM,

Now that you cleared that up(broke it down),I understand
what you meant although it came off as arrogant. All
your apologies are accepted and no offense was taken.
Sure, my replies referred more to Word, as understood by
Jonathan. The way I see it, my questions were answered
directly and without confusion from the person giving
advice. Your good will and advice are appreciated.
 
J

JGM

Hi Vtown,

Thanks for the reply, I appreciate it as well.

Cheers!

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

"Vtown" <[email protected]> a écrit dans le message de
[email protected]...

Monsieur JGM,

Now that you cleared that up(broke it down),I understand
what you meant although it came off as arrogant. All
your apologies are accepted and no offense was taken.
Sure, my replies referred more to Word, as understood by
Jonathan. The way I see it, my questions were answered
directly and without confusion from the person giving
advice. Your good will and advice are appreciated.
 

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