Word.Tips.Net Welcome toWord.Tips.Net

Helpful Links

Tips.Net Home
WordTips Home

Ask a Word Question
Make a Comment

Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

Newest Tips

Arranging Document Windows

Specifying a Backup Location

Controlling Chart Gridlines

Merging Table Cells

Collapsing and Expanding Subdocuments

Zooming With the Keyboard

Initiating a New Search

 

Macro Error when Closing Document

Summary: Word can run macros both when opening and closing a document, if such macros exist. If there is an error in the macro, you'll see an error message. How you get rid of the error message is described in this tip. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)

Patricia Malyon is experiencing a situation where she is getting errors whenever she closes a document. Specifically, the error says "Compile Error in Hidden Module: Main." This error is caused by a macro that is somehow failing to run, as Word expects it to, every time a document closes.

If this error occurs with every document being closed, there is a good chance that the offending macro is in the Normal.dot template. Another clue is that the "Main" reference indicates that the macro is probably from an older, pre-Word 97 version of Word. (Prior to Word 97 the macro language used was WordBasic, and it used Main as the name of the primary entry point for a macro.) If you've upgraded recently to a newer version of Word, then the macro that used to work fine under your older version of Word may now have problems in the newer version.

The only way to fix such a problem is to examine the add-ins and macros associated with your documents and templates. Tracking down the problem can be frustrating, particularly if you are unfamiliar with macros and the VBA Editor, but it is the only way to really fix the problem. Chances are good that the offending macro is part of (or referenced in) a FileClose or AutoClose macro.

One good online source of information for problems such as this is at the Word MVP site. Take a look at the following Web page, particularly section four. It includes information and guidance that may be helpful:

http://word.mvps.org/FAQs/AppErrors/ProbsOpeningWord.htm

Tip #188 applies to Microsoft Word versions: 97 | 2000 | 2002 | 2003

More Power! For some people, the prospect of creating Word macros can be scary. WordTips: The Macros can help you conquer your fears and you'll discover you're much more confident and productive as you make Word do exactly what you want. This is an invaluable source for learning macros. You are introduced to the topic in bite-sized chunks, pulled from past issues of WordTips. Learn at your own pace, exactly the way you want.
 
Check out WordTips: The Macros today!