Microsoft Word and Excel Macros

Although applications may share a common macro language, each has its own structure and way of operating. Macros written for one type of application usually do not work in another. Manipulating a document in Word is completely different than moving around in an Excel workbook. Even similar events, such as adding together the numbers from two cells, bears little resemblance to each other behind the scenes. To understand macro viruses, you must understand how each application uses macros.

Word Macros

Although macros in Word can be saved in a document, they are more often stored in a separate file type called a template (prior to Word 97, macros had to be stored in a template). The template can contain many of the settings a user wants to include in her default document, like font type, toolbar settings, key assignments, styles, font size, page layout, etc. Every Word document is based on a template, and that template is linked to the document. Whenever an existing or new document is opened, the template settings are applied first. A global template , usually called NORMAL.DOT , is in memory every time Word is loaded. This is a favorite of virus writers, because a macro placed there is able to infect more quickly.

Tip

When you choose File New to start a new document, Word will prompt you to choose one of your available templates to use. The Blank Document template is based on Normal.dot.

Word comes with dozens of predefined templates for form letters, ...

Get Malicious Mobile Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.