Here at BrightCarbon we’re always looking for new ways to improve our own PowerPoint productivity and then share that knowledge with the presentation community (that includes you, by the way!). One of the ways we do this is by using VBA code to automate and extend the functionality of PowerPoint. We publish free PowerPoint VBA code snippets here in our blog for you to use. This article explains how to grab the code from our articles and use it in your PowerPoint project, so that you can take your productivity to the next level!

What is VBA?

Visual Basic for Applications (VBA) is a programming environment for Microsoft Office applications. It’s included with your installation of Office by default (unless your system administrator has deactivated it). PowerPoint VBA provides you with a way to do one of two things using macros and add-ins: 

  1. Automate PowerPoint: If you ever find yourself repeating the same task over and over again, VBA could be your new best friend. Let’s say you have 100 slides and you need to unhide all hidden objects across all those slides. That could take you many eye-straining minutes, but with a PowerPoint VBA it takes around a second.
  1. Extend PowerPoint: Sometimes PowerPoint doesn’t have the feature you need to complete your task. As an example, if you end up deleting default layouts from a template, there’s no easy way in PowerPoint to get them back. This article includes PowerPoint VBA code to do just that!

How to open the VBE (Visual Basic Editor)

Getting to meet your VBA friend is very simple. With PowerPoint open and at least one presentation file open, press Alt+F11* on your keyboard. This will open the VBE (Visual Basic Editor): 

PowerPoint VBE No Modules

*If for some reason Alt+F11 isn’t mapped on your keyboard you can right click anywhere on the ribbon, select Customize the Ribbon… and in the window that appears, tick the Developer Tab check box over on the right hand side before clicking OK to close the window. Now you can click the Visual Basic button within this tab: 

 PowerPoint Developer Tab Visual Basic

Adding PowerPoint VBA code 

To add some VBA code, you need a container to put it in so go ahead and click Insert from the menu and then select Module: 

PowerPoint VBE Insert Module 

You now have a module ready to paste the VBA code into from one of our blog articles: 

PowerPoint VBE Module Inserted 

Copy the VBA code from the required blog article by double-clicking on it and then paste it into the Module1 window above. Here’s a very simple example of some code to display a message dialogue:

' PowerPoint VBA Macro to display Hello World message.
' Copyright (c) 2019 BrightCarbon Ltd. All Rights Reserved.
' Source code is provided under Creative Commons Attribution License
' This means you must give credit for our original creation in the following form:
' "Includes code created by BrightCarbon Ltd. ("
' Commons Deed @
' License Legal @
' Purpose : Displays a dialog box with a Hello World text message.
' Author : Jamie Garroch
' Date : 06MAY2019
' Website :

Sub HelloWorld()
 MsgBox "Hello World!", vbInformation + vbOKOnly, "This is my first VBA Macro"
End Sub

You should now see something like this: 

PowerPoint VBA

Because this code is just a single Sub procedure called HelloWorld, it’s referred to as a macro. 

Running the PowerPoint VBA macro 

Now you have the macro in your presentation you can use Alt+Tab to return to the more familiar PowerPoint window. From here, the macro can be run by pressing Alt+F8 on your keyboard (or by clicking the Macros button in the Developer tab) which opens a window containing a list of available macros: 

PowerPoint VBA


Saving your file 

With the macro(s) in your presentation file you can now use it in that file or with any other PowerPoint file you have open. Bear in mind that to use your macros, the file that contains them must be open. You can add as many modules and macros as you like in a PowerPoint file so you could create your own library of macros in a single file that you then access from all other decks. When you have multiple PowerPoint files open, make sure you select the file that contains your macros in the Macro window by clicking the Macro in drop down:


Once you’ve added VBA code to your presentation, PowerPoint will ask you to save it as a pptm file (the ‘m’ stands for macro) instead of the more familiar pptx formatYou can go ahead and do this to either keep an archive copy of your code-enabled project or to create your personal macro library. 

If you want to distribute your presentation, it’s advisable to save it using the familiar pptx format so that your recipients don’t see lots of verbose security messages when opening pptm files! 

You can make your file saveable as a standard presentation again by rightclicking on each code module in the project explorer pane, clicking Remove ModuleX and either click Yes (if you want to keep a backup of the modules independently of your presentation) or No when asked if you want to save the module before removing it: 

Now your presentation doesn’t include any code and you can save it as a pptx file. 

So, there you have it. You now know how to open the VBE, insert a PowerPoint VBA code module, paste code into it, run the macro and save the file in either pptm or pptx formats. All you need is a cool macro to make your daily life even easier. Keep checking in with our blog for more useful macros – like this one on restoring default slide master layouts! And let us know if there’s any particular macros you’d like to see by commenting below.

Leave a comment
Written by

Jamie Garroch

Senior technical consultant

View Jamie Garroch's profile

Related articles

Apr 2020

PowerPoint has evolved into an app which is the Swiss Army knife of content creation, not only for presentations but also printed collaterals, videos and even interactive presentations. In this second part of our series on supercharging PowerPoint interactive presentations with VBA we look at how you can provide your users with visual feedback for active areas of your slide using a mouse hover technique.

  1. Image of Joao Marques Joao Marques says:

    very simple, very explicit, very good help for a beginner vba programmer in powerpoint. Thanks

  2. Image of Dave C Dave C says:

    great resource, thanks. I’ve used VBA for years in MSaccess, and this is a good refresher for me.

  3. Image of charles Lathrop charles Lathrop says:

    I am trying to make a ppt file that loops until stopped. then I save it as a video. the ppt ran and looped continuously. Once recorded as video it stopped looping. do you have code to make ppt work when in video format

    • Image of Jamie Garroch Jamie Garroch says:

      Hi Charles. As soon as you export a PowerPoint deck as a video all the PowerPoint functionality is removed as the file is magically transformed into an MP4 file, without VBA (sob sob). The only way to make the video loop is to use the looping feature of your video player.

Leave a Reply

Join the BrightCarbon mailing list for monthly invites and resources

Tell me more!

I absolutely love this, thank you so much. I have shared your fabulous resources with many folks. Thanks for all the brilliant work you do!

Michaela Butterworth State of Kansas