Link to home
Start Free TrialLog in
Avatar of cybeh
cybeh

asked on

Auto run Macro upon document open

Hi,

May I know what can I do in order to make my Macro auto run while I open the document?

Beside that, how can I set my word application so that it will take this macro as only macro that allowed to autorun? As I don't wish it to open up word doc that contain macro as virus.

Please advice.
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Hi cybeh,

> May I know what can I do in order to make my Macro auto run while I
> open the document?

Go to the ThisDocument module, and create a Document_Open sub.

> Beside that, how can I set my word application so that it will take
> this macro as only macro that allowed to autorun? As I don't wish it
> to open up word doc that contain macro as virus.

Not sure what you mean here...

Regards,

Patrick
Avatar of cybeh
cybeh

ASKER

Under the Tools -> Security Level,

If I set it to High, then, the Document_Open will not load automatically.

I saw that there is a tab called "trusted Publishers". May I know how can I add my macro to the list? Please Advice.
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cybeh

ASKER

Hi,

I do have a form show during the macro. When I set the security to medium, and click on the enable macro while prompt, it will still not auto run. Please advice. (The macro works fine under "security - None")
Hi - This is how I handled the same problem at my law firm.  Don't know if this is an alternative for you but...

I basically saved the "documents" as "templates".  Then make sure "Trust all add-ins and templates" is checked under Trusted Sources.  You access your template under File, New and the macro will run.  You will need to rename the macro to Document_New however - not Document_Open.

In further response to your question -
I think the Document_Open macro doesn't run after you enable macros because it's "interrupted" so to speak.
As matthewspatrick said, you should create a certificate and add it under the Trusted Sources.
Otherwise - and I'm not recommending this - but setting your macro security to low will enable it to run properly without a digital certificate.

From Word Help:
"A less secure option is to change the security level to Low. If you do use Low, you use Microsoft Word in its least secure setting. Be sure to take the following precautions to minimize your risk of getting a macro virus infection on your computer: Run a specialized antivirus software that can check files and add-ins for macro viruses and keep this software up to date, and be sure all the macros that you use are from trusted sources."

Good luck,
Joanne


Create a template.  Then create the macro using the name "AutoNew".  Using that name causes it to run automatically.  Make sure you change the "macros in" dropdown to the name of the template you are using, since "all active templates and documents" is the default.
Avatar of cybeh

ASKER

Thanks !
You're welcome :)