Share this Page URL
Help

Part: VII Automating Office with Macros ... > Building Custom Applications with VB... - Pg. 1070

1070 Chapter 43. Building Custom Applications with VBA In this chapter Controlling How VBA Applications Start Using Auto Macros Opening, Closing, and Creating New Documents Using VBA to Add Text Displaying Messages Displaying Messages in Word with VBA Displaying Office-Standard Dialog Boxes Creating Custom Dialog Boxes Troubleshooting Secrets of the Office Masters: Custom Dialog Boxes in VBA Controlling How VBA Applications Start There are countless ways to run a macro. The most direct way, of course, is to work your way through the pull-down menus into the Macros dialog box, where you can make a selection and then click Run. But there are far more efficient and productive ways to automate work processes, especially when you're creating a document, workbook, or presentation that you want to pass along to other users. You can create a macro that runs automatically every time a user opens a specific Word document or Excel workbook, for example. Excel keeps track of 20 workbook-related events (Before Print, Before Save, when a Sheet is Activated), and you can write macros that run when any of those events "fire." Use these Auto macros to ask the user for initial information for a report, or to update a worksheet with up-to-the-minute data off the Web every time a user opens a workbook. You can also set up "hot" areas within a document, worksheet, or PowerPoint slide, so that clicking a bit of text or a graphic region runs a macro. PowerPoint lets you run a macro by passing the mouse pointer over a "hot" spot on a slide. In Outlook, you can specify that a macro be run when the application starts or quits, when new mail arrives, when a message is sent, or when a Reminder shows up onscreen. FrontPage and Publisher have the least developed macro-triggering capabilities of all the Office applications. Without a lot of work, the most you can do is put a macro on the menu or a toolbar. At the high end, you can even replace Word's built-in functions with macros of your own devising. For example, you can create your own File Open routine to run in place of Word's File Open. That solution might come in handy if your company uses nonstandard file extensions and you want to see a list of those files every time you choose File, Open.