How to make a vba program to run when a word document open?

H

hana halu

Hi all
Maybe the question is extremely easy(flushing).
i am addlehead about VBA.
And i have not a Book of VBA programming.
so ,if u answer my question ,i want u can paste a piece of code.

Thanks a lot
 
M

Malcolm Smith

Place your code in the Document_Open event handler of the template or
document. That way when the document is opened the code therein will run.

By the way, it is normally polite to spell 'you' with three letters and
not one. If you can't be bothered to spell properly then, equally, I
can't be bothered to paste any code which I would normally have given you.

- Malc
 
H

hana halu

Mr.Smith
Sorry£¡very sorry !
i am a chinese , and my english is very very poor.
we talk each other in chatroom all spell 'you' as 'u', but always do not
know this is disrespect and sin.
i have a fat lot chance talk with a english or a american face to face.
Pls forgive for my unwisdom.
say sorry again!
i will memorize your dehortation by heart and tell your memorize to my
comate.
 
H

hana halu

Mr.Smith
you can affirm that my mother tongue is not English from my awful english.
so , i wait a sample code cordially.
need you help, Mr.Smith,i can affirm that you are a magnanimous man.
i just get a piece of code to make the document show a message"helloworld"
right away when it opened.
and where the code will be type in ?(i never use WORD VBA (even a touch )

thank you !
 
J

Jonathan West

hana halu said:
Mr.Smith
you can affirm that my mother tongue is not English from my awful english.
so , i wait a sample code cordially.
need you help, Mr.Smith,i can affirm that you are a magnanimous man.
i just get a piece of code to make the document show a message"helloworld"
right away when it opened.
and where the code will be type in ?(i never use WORD VBA (even a touch )

thank you !

Hi hana

These two articles will help you

Running a macro automatically when a document is created, opened or closed
http://word.mvps.org/FAQs/MacrosVBA/DocumentEvents.htm

What do I do with macros sent to me by other newsgroup readers to help me
out?
http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm
 
M

Malcolm Smith

What you need to do is to place some code in the Document_Open() event.
To enter the editor press Alt-F11 when Word is open.

That's all you have to do; it's as simple as that.


For example locate the Document_Open event and then enter the code:

MsgBox "Hello World", vbokonly, "My first VBA program"

save the document and then re-open it!

Bingo!

- Malc
www.dragondrop.com


p.s. Using 'u' is fine if one is an illiterate American guttersnipe who
somehow imagines that it's cool to wear a baseball cap on back to front
and trousers large enough to cover the Hindenburg.
 
H

hana halu

Thank you ,
Jonathan West,you give a great help!
thank you for the two articles that you recommend.
 
H

hana halu

Mr.Smith
i think that you are a humorist(because of your "p.s." :) ) .
in fact i have downloaded a VBA tutorial(a PDF file) just now.
thank you !

p.s. In china ,there is bevy, their duds like people you talk about
stupendously.
but they are not illiterate or come form slum . by contraries,they are
almost university man or rich man .they think that such duds can make them
like stylish cultured american :)
 
C

Chad DeMeyer

hana halu,

if ima incorrect most humble and gracious apologies
but you sound more like someone pretending to not have a good command of
English than someone who actually stumbles over the language
i think it is you who are humorist no?

regards
chad
 

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