Using PowerPoint Scripts & Macros
PowerPoint and other Microsoft Office programs comes with VBA, Visual Basic for Applications. VBA is an implementation of Microsoft’s event-driven programming language Visual Basic 6 and let you run scripts and macros in the popular Microsoft Office applications. VBA enables building user defined functions, automating processes and accessing Windows API and other low-level functionality through dynamic-link libraries (DLLs). Office for Mac also supports VBA since PowerPoint 2008 and other Microsoft applications such as Microsoft MapPoint and Microsoft Visio have support, too.
By using VBA you can write or run your own Macros and PowerPoint Scripts to make richer PowerPoint presentations with custom application code. Here we will review what is available in the PowerPoint interface to work with Macros and Scripts. This can be very handy if you plan to code your own Macros or someone shared a script that you want to run in PowerPoint.
Install Developer menu in PowerPoint 2010
To install the developer menu in PowerPoint you’d need to customize the ribbon. Right click in the PowerPoint ribbon and then choose Customize the Ribbon.
If you plan to use Macros in PowerPoint more often, it is recommended to install the Developer toolbar as a menu.
This will add a new menu to PowerPoint with Developer buttons. We will use it to access the VBA editor but you can alternatively use Alt-F11.
This toolbar can be helpful if you plan to use developer tools, like accessing Visual Basic for Applications, run macros, configure add ins or even create a Form using controls.
Let’s start inserting a new module. Here is where you will place your VBA code or scripts.
You can also import macros and scripts from file if you have the code that downloaded from Internet or someone shared by email.
If you want to insert a simple VBA code example in PowerPoint Macro, then let’s start using this simple snippet. Here we will show you how to create a random number in a shape as an Action, using Macros.
When you click on the following shape, the number will be updated with a random value between 0 and 99.
Enter the module you have created earlier and add the following subroutine.
Now, you can assign this macro to the shape as an action. Go to PowerPoint editor and then select the shape where you want to assign the action. Now go to Insert menu and click to insert an Action.
Finally, play the slideshow and try clicking on the shape. This will update the shape text with a random value.
It is important to notice that any macro enabled PowerPoint file should be saved as a PPTM presentation file format. This is a requirement in newer versions of PowerPoint for security concerns, especially when you download presentations from Internet. It is recommended to check the Getting Started with VBA in PowerPoint 2010 to learn more about how to start using VBA. If you want to download this free macro and script for PowerPoint, click on the following download link to download the PowerPoint example. Random Number PowerPoint Script (1979)