How to Add VBA Code in PowerPoint Step-by-Step Guide
Step 1: Enable the Developer Tab 1. Go to File → Options. 2. Select Customize Ribbon. 3. Check the Developer option and click OK. → The Developer tab will now appear in your Ribbon.
Step 2: Open the VBA Editor 1. Click Developer → Visual Basic, or press Alt + F11. 2. The VBA Editor (VBE) window will open. 3. This is where you can write or edit your VBA code.
Step 3: Insert a New Module 1. In the VBA Editor, locate your presentation in the Project Explorer. 2. Right-click → Insert → Module. 3. A blank code window appears — paste or write your VBA code here.
Step 4: Example VBA Code Sub HelloWorld() MsgBox "Hello, this is your first VBA code in PowerPoint!" End Sub
Step 5–6: Run and Save the Code • Run the code via F5 or Developer → Macros → Run. • Save your file as a .pptm (Macro-Enabled Presentation). • Regular .pptx files cannot store macros.
Step 7: Adjust Macro Security 1. Go to File → Options → Trust Center → Trust Center Settings → Macro Settings. 2. Choose 'Enable all macros' or 'Disable all macros with notification'.