running a macro when word opens

rodney_malodney

Board Regular
Joined
Jul 19, 2005
Messages
116
hi, ive got a word file that when opened i need it to run a macro, as far as i can guess this is the right code:

sub document_open ()

but am i right or not as it doesnt appear to work????
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
.

Hi, you'll want to name the subroutine AutoOpen and the code should be placed in a module UNDER the document you want this to run on when you open it. Or you can name the module AutoOpen and the subroutine in the module should be Main (I like to code it this way as Auto routines are usually key).

If you don't place it under the document in question and instead place the code in the Normal.Dot it will run everytime any document is opened.

The explanation from the VBA help file is slightly convoluted but understandable. When in Word VBA, do a search on "Auto Macros".

:)
 
Upvote 0

Forum statistics

Threads
1,224,845
Messages
6,181,298
Members
453,030
Latest member
PG626

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top