Many activities you perform in Project can be repetitive. To save time, you can record a macro that captures keystrokes and mouse actions. The macro is recorded in Microsoft Visual Basic for Applications (VBA), the built-in macro programming language of the Microsoft Office System. You can do sophisticated things with VBA, but you can record and play back simple macros without ever directly seeing or working with VBA code.
The macros you create are stored in the global template by default, so they are available to you whenever Project is running. (In fact, macros, toolbars, and import/export maps are unique in that when you create or customize them, Project will store them in the global template rather than the active project plan by default.) The project plan for which you originally created the macro need not be open to run the macro in other project plans. If you want, you can use the Organizer to copy the macro from the global template to another project plan to give it to a friend, for example.
Publishing a project plan in HTML format is a great way to share project details on an intranet or the World Wide Web. However, it’s likely the details you initially publish will become obsolete quickly as the project plan is updated. Republishing is a repetitive task that is ideal for automation through a macro. In this exercise, you record and run a macro in the Parnell Aerospace Promo 18 project plan that publishes the project plan to HTML format.
On the Tools menu, point to Macro, and then click Record New Macro.
The Record Macro dialog box appears.
In the Macro name box, type Save_As_Web_Page
Macro names must begin with a letter and cannot contain spaces. To improve the readability of your macro names, you can use an underscore (_) in place of a space. For example, rather than naming a macro SaveAsWebPage, you can name it Save_As_Web_Page.
For this macro, we will not use a shortcut key. When recording other macros, note that you cannot use a [Ctrl]+ key combination already reserved by Project, so combinations like [Ctrl] +[F] (the keyboard shortcut for Find) and [Ctrl] + [G] (Go To) are unavailable. When you click OK to close the dialog box, Project alerts you if you need to choose a different key combination.
In the Store macro in box, click This Project to store the macro in the active project plan.
When a macro is stored in a project plan, the macro can be used by any project plan when the project plan that contains the macro is open. The other option, Global File, refers to the global template. In this exercise, you will not customize your global template.
In the Description box, select the boilerplate text, and replace it by typing Saves a copy of the Gantt Chart view and project data to a web page.
Your screen should look similar to the following illustration:
The description is useful to help identify the actions the macro will perform.
Project begins recording the new macro. Project does not literally record and play back every mouse movement and passing second, but records only the results of the keystrokes and mouse actions you make. Do not feel rushed to complete the recording of the macro.
On the View menu, click Gantt Chart.
Even though the project plan is already showing the Gantt Chart view, including this step in the macro records the action so that if the project plan were initially in a different view, the macro would switch to the Gantt Chart view.
On the View menu, click Zoom.
In the Zoom dialog box, select Entire Project, and then click OK.
Project adjusts the timescale to display the entire project. Your screen should look similar to the following illustration:
On the Standard toolbar click the Copy Picture button.
The Copy Picture dialog box appears.
Under Render image, click To GIF image file, and then click OK.
The folder location and file name proposed for the GIF image are the same as those of the project plan, which is fine.
On the File menu, click Save As Web Page, and then click Save.
Again, the folder location and file name proposed for the HTML file are the same as those of the project plan, which is fine.
When you click Save, the Export Wizard appears.
In the Export Wizard, click the Next button.
The Map page of the Export Wizard appears.
Click Use existing map, and then click the Next button.
The Map Selection page of the Export Wizard appears.
Under Choose a map for your data, click Export to HTML using standard template, and then click the Next button.
The Map Options page of the Export Wizard appears.
Under HTML Options, click Include image file in HTML page, and then click Finish.
The Export Wizard saves the Web page as you’ve specified. To wrap up the actions recorded in the macro, you will reset the timescale.
On the View menu, click Zoom, click Reset, and then click OK.
Now you are ready to stop recording.
On the Tools menu, point to Macro, and then click Stop Recorder.
Next you will run the macro to see it play back.
On the Tools menu, point to Macro, and then click Macros.
The Macros dialog box appears.
In the Macro name box, click Parnell Aerospace Promo 18.mpp! Save_As_Web_Page, and then click the Run button.
The macro begins running but pauses as soon as Project generates a confirmation message to replace the existing GIF image file.
Your security level setting in Project affects Project’s ability to run macros that you record, or that you get from others. You may not have set the security level directly, but it may have been set when you installed Project, or by a system policy within your organization.
Click Overwrite, and then click OK to overwrite the previously created Web page.
The macro republishes the project plan to HTML format. Next you’ll see the results of the macro’s actions.
In Windows Explorer, navigate to the Chapter 18 Customizing folder, and double- click the Parnell Aerospace Promo 18.html file to open it in your browser.
The Web page (consisting of the HTML file and related GIF image) appears in your browser. Your screen should look similar to the following illustration:
Leave the Web page open in your browser; you’ll return to it in the next exercise.
Switch back to the Parnell Aerospace Promo 18 project plan in Project.
This macro would be very useful if the Parnell project manager needed to republish the details of the project plan frequently. For example, the project manager could republish it at regular intervals during the planning stage, when the details are being developed, and then again during the execution stage, when the effects of actual progress change the remaining scheduled work.