After recording a macro, PowerPoint tries to reduce the sequence of recorded PowerPoint commands to a series of VBA commands that would have the same effect. If you find that you want to record more powerful macros, you may need to use the VB Editor. The VB Editor is a separate program you can use to customize, create, and debug macros using the VB programming language. Editing a Macro Using the VB EditorYou may find that sometimes a macro is not working the way you had intended. This may be caused by the way your mouse and keystrokes were converted into Visual Basic. For example, if you record a macro and press the Page Down key five times (from slide one), it will be rewritten in Visual Basic as a macro that goes to slide six. To create a macro that would move down five slides, you would have to use the Visual Basic Editor to edit the default macro and make it work the way you intended. To use the VB Editor and edit a specific macro:
Using the VB Editor to Create a MacroBy including the Visual Basic Editor (VBE), PowerPoint gives you a built-in programming environment with a wealth of features. The editor is a subset of the popular Visual Basic language. Use the editor to edit, write, debug, and manage macro script code. The editor also has many useful windows that help you explore the VBA language. You can open the editor in one of two ways:
There are entire books that focus on Visual Basic's impressive capabilities, but the following sections just highlight the basic features you need to create macros. You can easily cut and paste or drag and drop sample code into a macro module. Open the Visual Basic Editor and choose View, Code from the menu, or press F7 to display the Visual Basic Editor window. After you copy or add VBA code to the window, the macros are automatically displayed and available in PowerPoint's Macro dialog box. The Visual Basic Help files and Object Browser are useful reference sources; they can give you insight into the objects with which macro subroutines can work. |