Writing Macros in MS Office Apps
The writing of Office macros is strongly discouraged within the department for security reasons. The first viruses required considerable technical ability to write but an enormous number are now macro viruses which take advantage of the feature in Microsoft Office programs to automatically run a script when documents such as Word (.doc) or Excel (.xls) are opened. If you start writing macros for all your Word documents, for example to insert a page count, and you email this to someone else, they have to know that your document is virus free before opening it to save them the risk of infection. Some companies block any document that contains a macro for this reason; your harmless email may never get to its recipient.
Macros are a good way of speeding up long and complicated operations but they do incur a lot of possible problems. Most people don't need to use them for their day-to-day work but if you do need them, beware, you might be making more work for yourself than not using them in the first place.
Tips for people who have to use macros
- Don't save any macros to the Normal.dot file (Word) as these will get propagated to all new documents. It also means that other users of your pc will inherit your macros possibly without realising it.
- Make sure your settings in all Office applications checks for documents that contain macros and warns you if they do. In Word97, for example, look in Tools -> Options -> General tab -> 'Macro Virus Protection'. Make sure this is ticked!
- If sending someone a document with macros embedded within it, warn them before sending it, letting them know that you are about to email them a document that contains macros. That way, if they don't receive it, they can then ask you to re-send it but in a zip file.
- Don't assume that just because your pc has a virus checking program installed, any attachment that you may receive via email will be safe when you open it. If you get into the habit of writing and using macros, you may become lax in your attitude towards the risks involved when working with them; one day you may get caught out. There are currently (depending on how you measure) something like 60-75,000 known viruses and worms. While the likelihood of more than a few hundred of these ever being in circulation at any one time is quite small, some 10-20 new viruses or variants appear a day. When one does escape "into the wild", network worms and mass mailer viruses can sometimes spread worldwide before anti-virus vendors have had time to produce updates. Even daily anti-virus updates are not always enough to ensure safety from all possible threats.
- Find out if you really need to write a macro to do the task you want to do. Have you searched the web for tips and advice from other people who have had the same question as you? MS Office products are bundled with hundreds of options and shortcuts; make sure there is no other way to do what you want to achieve before walking down the road of macro scripting.