Share via

Word document Auto_open

Anonymous
2016-08-24T15:40:47+00:00

I have several templates that I have created. I have a mix of problems with the Macros that correspond with one specific template as its the only one with auto macros. Everytime I open any document in word, it tries to run the auto_open macro creating a mess of errors. On top of this, after I save the document that I've created from the template, the auto_open runs again and pulls another invoice number from the batch. What did i do wrong and how can i fix it.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2016-08-25T07:05:02+00:00

    The whole point of an AutoOpen macro is that it runs when the document is opened. If you only want to run the macro when a new document is created from the template rename it AutoNew.

    Was this answer helpful?

    0 comments No comments
  2. Jay Freedman 207.7K Reputation points Volunteer Moderator
    2016-08-24T21:04:48+00:00

    Does this happen in documents that are not based on the problem template?

    Exactly what do you mean by "a mess of errors"? Are there error message boxes, and if so, exactly what do they say?

    For the other parts of your problem, it won't be possible to diagnose unless you post the code of the macro.

    A couple of notes:

    1. Word doesn't recognize auto_open (with the underscore) as an automatic macro's name -- it should be AutoOpen. However, a macro named Document_Open stored in the ThisDocument module will behave the same way.
    2. If the macro really is AutoOpen, it could be running after a save if (a) there is code that closes and reopens the document or (b) if there is code that explicitly calls AutoOpen like any other procedure.
    3. When you open a document, you can prevent auto macros from running by holding down the Shift key. In code, you can create or open a document without triggering the auto macros by executing the statement

    WordBasic.DisableAutoMacros 1   'Disables auto macros

    before opening, and

    WordBasic.DisableAutoMacros 0   'Enables auto macros

    after opening. (http://www.word.mvps.org/FAQs/MacrosVBA/WordBasicCommands.htm)

    Was this answer helpful?

    0 comments No comments