by Allen Wyatt
(last updated April 13, 2017)
In Word, macros are written in a language called Visual Basic for Applications, or VBA. When you write a macro, you need to test it and correct any errors in the macro. This process is called debugging. The process of debugging a macro is the same as debugging in any other programming language. All you need to do is step through the macro, one command at a time, and make sure it works as you think it should. You do this by viewing both the windows for your macro and a test document. As you step through the macro (using the commands available in the Debug menu of the VBA Editor), you can correct any errors you locate.
As you are debugging macros, you need to make sure you think through every possible way the macro could be used and all the possible conditions that could exist at the time the macro is invoked. Try the macro out in all these ways and under all these conditions. In this way, you will make your macro much more useful.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (751) applies to Microsoft Word 97, 2000, 2002, and 2003.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Macros are often used to process information stored in documents. Usually the processing involves some sort of iterative ...Discover More
Need to know if a number in a macro is odd or even? It's easy to figure out with the simple calculation shown in this tip.Discover More
When writing a macro, a common task is the need to compare two strings. You can do this by "normalizing" the strings, as ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.