Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

PowerPoint VBA - Run Macro When Slide Changes in Edit Mode

I know I could do the following to run code when the slide is changed in presentation mode -

I'm wanting to know if it is possible to do this when ever a slide is changed outside of the slideshow i.e. the presentation is in edit mode so if I clicked on another slide it would run the code. Is this possible?

Thanks in advance!

  • microsoft-powerpoint

You could probably do something along the lines of:

1) Trap the SelectionChange event

2) When the event fires, check to see that the current slide is not the same as it was the last time you trapped a SelectionChange event (because the event fires when you select different shapes as well as different slides).

3) If it's a different slide, run your code and record the index of the current slide (to check against the next time the event fires)

You'd need to do this in an add-in.

The SlideSelectionChanged event might be a better one to respond to, though. https://msdn.microsoft.com/en-us/library/ff745869.aspx

Steve Rindsberg's user avatar

  • Thanks for the reply! I was hoping to avoid the need to use an add in but having looked around the internet I guessed this was heading that way. Thanks for the confirmation though! –  user613286 Jul 4, 2016 at 18:12

You must log in to answer this question.

  • The Overflow Blog
  • You should keep a developer’s journal
  • Would you board a plane safety-tested by GenAI?
  • Featured on Meta
  • Testing a new version of Stack Overflow Jobs
  • What deliverables would you like to see out of a working group?

Hot Network Questions

  • Is it correct to put a section separator (double thin lines) in the middle of a measure?
  • A ring whose all elements are zero divisors
  • Estimate Box-Cox Transformation Lambda Using Skewness and Kurtosis
  • Why does Israel prefer Egypt as a mediator over Qatar?
  • What is the difference between Clear and Remove?
  • What do people call a chart with a strip of peak values in time intervals?
  • What is the product in the category of sets with only the injections as maps?
  • Vacuum solutions in presence of mass?
  • Source for Zohar reference
  • Why does my object get no light or shadows and only another object?
  • Including all constraints in a geometry problem
  • I was filling and activating my new Yuasa battery when I noticed a slight smell of rotten eggs
  • Very poor communication by most of my colleagues
  • What should I do if I messed up my pre-thesis project and I just want to end it as soon as possible and switch a group for master thesis?
  • Is this a solvable Numberlink?
  • The UK's population or The UK population
  • By how much does sodium bicarbonate raise pH
  • Regarding a Coin Toss Experiment by Neil DeGrasse Tyson, and its validity
  • GNU sort command does not sort words of different lengths with common prefixes correctly when using field delimiter
  • Which Palestinian government is getting recognized?
  • Does using electricity from the grid in the U.S. result in more greenhouse gas emissions than using propane?
  • Is "id tempus est" grammatical?
  • Path from humanities undergrad to math PhD
  • How to horizontally align the dashed lines to the intersection point?

vba powerpoint exit presentation mode

vba powerpoint exit presentation mode

Microsoft Learn Q&A needs your feedback! Learn More

May 20, 2024

Microsoft Learn Q&A needs your feedback!

Want to earn $25 for telling us how you feel about the current Microsoft Learn Q&A thread experience? Help our research team understand how to make Q&A great for you.

Find out more!

Contribute to the Microsoft 365 and Office forum! Click  here  to learn more  💡

April 9, 2024

Contribute to the Microsoft 365 and Office forum!

Click  here  to learn more  💡

PowerPoint Forum Top Contributors: Steve Rindsberg  -  John Korchok  -  Bob Jones AKA: CyberTaz   ✅

May 10, 2024

PowerPoint Forum Top Contributors:

Steve Rindsberg  -  John Korchok  -  Bob Jones AKA: CyberTaz   ✅

  • Search the community and support articles
  • Microsoft 365 and Office
  • Search Community member

Ask a new question

DavidG4P

How to stop PowerPoint from exiting presentation mode after the last slide?

How can I stop PowerPoint from exiting presentation mode after the last slide of a presentation?

The presentation should also not run in an endless loop. 

After the last slide, the slide should simply stay open, even if clicking again or pressing the arrow down key.

How can this be achieved?

Report abuse

Reported content has been submitted​

Replies (8) 

Gloria Li MSFT

  • Microsoft Agent |

Thanks for sharing your experience in our community.

Based on your description, we are trying to test as you mentioned as below, when we go to the last slide and then click again/ press the arrow down key, the slide will be black and show “ End of slide show, click to exit ”, and click again which can back to the last slide, may I confirm this is what you mean?

vba powerpoint exit presentation mode

Regarding to your concern, if you just want to the last slide stay open after slide show, you might click File > Options > Advanced > uncheck End with black slide and check whether it will stay open without black slide.

vba powerpoint exit presentation mode

If this is not what you mean, please feel free to contact us, we’ll try our best to further investigate it. 😊

   

Best regards,

2 people found this reply helpful

Was this reply helpful? Yes No

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

Thanks for your feedback.

Thank you Gloria, I've also tried your approach. However, I'd prefer not to have a black slide, and also to not accidentally leaving presentation mode by clicking / pressing the arrow down key one or a few times too often.

John Korchok

  • Volunteer Moderator

Gloria has outlined the available options built into the program. An alternative is to duplicate your last slide several times so that if you keep pressing the down arrow, you get the same slide.

Thanks John & Gloria, I might try that then.

Steve Rindsberg

Another option:

Remove the End Show with Black slide checkmark as described above.

Then on the actual last slide add a full-slide rectangle, no-outline, 99% transparent fill.

It's now invisible.

Add a Go To Slide link on the rectangle and have it link to the slide itself.

Now when you click the slide during a show, it'll go to itself and since it and itself are identical, only you will be the wiser.

How cool is that Steve? Thanks!

Just to be sure before I try and poke around with transition settings and such: There is no way to prevent the arrow up/down keys from skipping any custom transition instantly, is there?

The only way to prevent various keystrokes from switching slides is to put the presentation in Kiosk mode, but if you do that, there'll be no navigation at all but the links/action settings you add to each slide or to the master/layouts.

1 person found this reply helpful

Question Info

  • Norsk Bokmål
  • Ελληνικά
  • Русский
  • עברית
  • العربية
  • ไทย
  • 한국어
  • 中文(简体)
  • 中文(繁體)
  • 日本語

How to use VBA in PowerPoint: A beginner’s guide

  • Written by: Jamie Garroch
  • Categories: PowerPoint productivity , Presentation technology
  • Comments: 45

vba powerpoint exit presentation mode

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 and also offer a PowerPoint automation service . 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:  

  • A utomate  PowerPo int:   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.
  • E xtend  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 :

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 b y  clicking the  Macros  button in the Developer tab)  which opens a window containing a list of available macros:  

PowerPoint VBA

Security Soup

The first time you add VBA code to a file, Microsoft assumes that it is safe because you added it. As soon as you save, close and reopen the file, Microsoft doesn’t know that it’s your code so it will disable it by default. You can tell the Office app to allow your code to run either by signing it with a digital certificate (beyond the scope of this article) or by lowering the security setting for the app. You can do this in PowerPoint by clicking File / Options / Trust Center / Trust Center Settings / Macro Settings and selecting this option shown below:

VBA Macro Settings

Saving your file  

vba powerpoint exit presentation mode

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  format .  You can go ahead and do this to  either  keep a n 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!  

Y ou can  make  your file saveable as a standard presentation again  by  right – click ing  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 :  

vba powerpoint exit presentation mode

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!

Got something extra you’d like PowerPoint to do?

Check out our PowerPoint automation service which provides you with a custom solution to your specific needs.

vba powerpoint exit presentation mode

Jamie Garroch

Principal technical consultant, related articles, how to consistently brand graphs and charts across microsoft office.

  • PowerPoint design / PowerPoint productivity
  • Comments: 1

How do you make sure that your graphs and charts have consistent branding across Excel, PowerPoint and Word? Learn how to create and use custom templates that support your brand identity across Microsoft Office.

vba powerpoint exit presentation mode

Changes to VBA Macro Security in Microsoft 365

  • Presentation technology / Industry insights
  • Comments: 2

You can do some really cool things in Microsoft Office with just a few lines of Visual Basic for Applications (VBA) - from creating your own custom formula in Excel to correcting branded content in PowerPoint to merging address data for a mail campaign in Word. And sometimes you need to share that VBA solution with colleagues and clients, via the Internet. A change that Microsoft rolled out at the end of March 2022 tweaks the process required by Windows users to gain access to this active content.

vba powerpoint exit presentation mode

Protecting your prized PowerPoint content

  • PowerPoint productivity / Presentation technology

Our comprehensive guide to password protecting PowerPoint files so your precious presentations stay just they you made them!

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

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

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

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.

Yeah, your best off recording a screen capture of the presentation running, then cutting it so it loops perfectly.

You can convert the video into gif file so that it will loop

Hi Jamie, thanks for the clear into, I am very new to this so that really helps. I am trying to develop a VBA macro that looks for the left hand mouse key being pressed and held down for more than two seconds whilst over a shape in slideshow mode. Once this is satisfied (i.e. two second press) for it then to hyperlink or take the user to a specified slide or even the next slide worst case.

I realise there is an automated/ built in feature (Action) that does this type of thing for a mouse click or mouse over but I really need a “long press” to activate if possible.

Any help appreciated.

Hi Simon and thanks for a great question. What you’re looking to do is pretty complex because VBA doesn’t natively support mouse actions in the PowerPoint slide show window. But, it is possible to use a Windows API (hence no Mac compatibility) called GetAsyncKeyState to gain access to mouse button click events. I had a look at this and quickly ran into a brick wall because an action link to a macro in slide show mode (Insert / Action / Mouse Click / Run macro) fires on the mouse up event, not mouse down. That means any corresponding VBA timer code can’t run until after the user releases the button and hence too late to detect if it was held down for two seconds. Maybe something could be done with the mouse over event to simulate what you need to achieve? Another approach could be to use the mouse down event on an invisible userform although that is also getting very involved with multiple Windows APIs. Depending on what you’re trying to do, you could also start the timer on click one, change the colour of the clicked shape and show countdown text before reverting to the original colour. If the user clicks a second time before the time expires, then the hyperlink is fired.

Valuable app

Hello I have a question:

Private Sub CommandButton2_Click() ActivePresentation.FollowHyperlink _ Address:=”http://192.168.16.49/?OUT1=ON”, _ NewWindow:=False, AddHistory:=False ActivePresentation.SlideShowWindow.View.GotoSlide (2)

Now it opens Chrome. but how can i make it that it opens te address en afther that shut down chrome.

Hi Tom. Your example should open the default browser at the URL specified by the Address parameter. For more information on the FollowHyperlink method, see this Microsoft documentation: https://docs.microsoft.com/en-us/office/vba/api/powerpoint.presentation.followhyperlink

Thank you very much! It’s exactly what I needed.

I have tried using your randomizing macro with a powerpoint – I must be doing something wrong, because it isn’t putting the slides in random order. Please advise! I copied the macro exactly (using cut & paste), and thought I was following all the directions here for how to use it in the powerpoint. But, no random presentation of the slides. Boo hoo!

Hi Marya. Let’s check that VBA is installed and enabled on your machine. Can you add the following macro to the VBE project (just below the existing one) and try to run it from the PowerPoint window using Alt+F8?

Sub CheckVBA() MsgBox “it’s working” End Sub

Make sure the quotes are the straight type.

I am trying to format my title page so that the number displayed is equal to the linked slide and updates automatically wherever the slide is moved. For example “about us” is on slide #5 and linked, so it goes to slide 5 when you click on the word. I need the number (in a separate text box) to update automatically to the slide number location that the link goes to.

Hi Mary and thanks for the question. It looks like you’re interested in some kind of automated agenda slide builder. That’s a fair bit of code to create and quite complex as it needs to handle events from PowerPoint to detect when slides have moved. It could be possible to write a simpler macro which you run manually each time you want to update that title page. You’d need start by finding a way to identify which objects are your numerical indicators. For example, if you named your objects in the selection pane (Alt+F10) “Agenda Link”, then is simple macro could be a starting place for you: Sub UpdateAgendaNumbers() Dim oSld As Slide Dim oShp As Shape Dim LinkedSlideIndex As Long On Error Resume Next For Each oSld In ActivePresentation.Slides For Each oShp In oSld.Shapes If oShp.Name = “Agenda Link” Then If oShp.ActionSettings(ppMouseClick).Action = ppActionHyperlink Then If oShp.HasTextFrame Then LinkedSlideIndex = Split(oShp.ActionSettings(ppMouseClick).Hyperlink.SubAddress, “,”)(1) oShp.TextFrame.TextRange.Text = LinkedSlideIndex End If End If End If Next Next End Sub

Great wealth of information. Have never used macros before but was looking to use them to help with this situation. At work we use Work Orders (created in Power Point) and are looking to include a sequential number to them (print 50-100 copies of one slide with the numbers) and if possible would like the number to continue from the last printed number…been trying to find some code to help but not having much luck possible partly due to being new to macros

That’s definitely something we could help design for you Joshua. If you’d like to discuss further, please click the Contact button at the top of this page.

I tried this changing the font color of text within the textbox. I used this to change the font color on a mouse over:

Public Sub GraphicHover(ByRef oGraphic As Shape)

oGraphic.TextFrame.TextRange.Font.Color.RGB = RGB(0, 130, 202)

and it works just fine. But, when I move the mouse off the text box, onto the invisible rectangle with this code attached to the mouseover event, it doesn’t change the text color back to it’s original color and remains the color I changed it to mentioned above. I know the mouseover event is being triggered because I checked “Highlight when mouse over” and I am seeing the highlight on the invisible rectangle:

Public Sub ResetGraphicHover(ByRef oCover As Shape) Dim oSld As Slide Dim oShp As Shape Set oSld = oCover.Parent For Each oShp In oSld.Shapes With oShp.TextFrame.TextRange.Font.Color If .RGB = RGB(0, 130, 202) Then .RGB = RGB(121, 135, 156) End With Next End Sub

Any clue where my ResetGraphicHover is failing?

Hi Dave. I took your code and it works for me. You could add a debug line after the For Each… line in the rest macro to check that (a) it’s firing and (b) which shapes are being looked at on your slide. To do that, add this:

Debug.Print oShp.Name

After you run the slide show, check the output in the VBE Immediate pane (Ctrl+G to toggle it).

Hi I am creating an interactive game (matching cards or concentration) in PowerPoint. If the 2 cards match, I need a pop-up text box to appear. If the 2 cards do not match, I need a sound to play.

I understand I need programming to make this happen. Please help or give alternative ways to achieve this. Thanks.

Hi Tammy. Have a look at this article which will help you: https://www.brightcarbon.com/blog/powerpoint-memory-game/

Hi Producer I will like to get comments on macros you can make available to me. Beautiful. I am using this approach frequently to make offline projects. Thanks. S. Fas

Excellent!!! Thank you!

You’re more than welcome Nataša!

Thank you! Is there any option to replace a font in the entire presentation for a specific character. Let’s say, I would like to change font only for dots in the deck but I would like to keep the rest in the original font. Any idea please? Thank you so much!

Hi Jan. You might be able to use the Replace Fonts feature found in the Home tab of PowerPoint under the Replace menu at the far end of the ribbon. If you need to use VBA then set up a nested loop to iterate all shapes within all slides and then use the oShp.TextFrame2.TextRange.Font object to change the font.

Exellent explenation. so beutiful. I am creating an interactive e learing quiz. Thanking you.

Hello! I have a client who’s interested in using tagging to help create searchable content within slides. For example, they have four different categories for slide content across multiple presentations (Overview, Market, Product, Country). I’d like to assign a different shape to represent each of the four categories, where a blue square might represent Overview slide content. Then, when someone uses the keyword “Overview” to search for overview content (on Teams or SharePoint), these slides are easily identified. Is this something that’s possible with VBA code?

Hi Linda. That’s a very good question! Given the need is to search via SharePoint, VBA probably won’t help here as the PowerPoint file needs to be opened for VBA to examine its content. I have a sneaking suspicion that if you add keywords in the Tags field under File / Info that SharePoint may use this. But, that’s at the file level rather than the slide level. We have a PowerPoint add-in called ShowMaker that might be of interest as it allows you to add category metadata to slides and then the presenter can use that to filter the deck and export the required content. You can find an overview of it here: https://www.brightcarbon.com/showmaker/ and we could set up a demo if you’re interested (please use the Contact button at the top of this page if that’s the case).

I’ve just created an elearning package in PowerPoint using VBA , I didn’t realise it could sum up text boxes within PowerPoint to mark the qualification at the end. Also used AWS text to speech over the top of the learning . Looks great

Sounds like a fun and successful project Stu! Thanks for sharing 🙂

I have a bit of a tricky one but hoping it is possible to do with VBA. We offer training services to multiple clients that can be customized but the majority of training is consistent from one client to the next (main changes are the slide masters/formatting and addition/removal of certain sections).

What we want to do is create one master (or multiple) training document(s), and then use VBA’s to link it to the client specific PowerPoint. We want to link the master rather than using the “reuse slide” command so that if we update one file the other will automatically update as well.

Not sure if it matters, but our company uses sharepoint as storage

Hi Dave and thanks for a great question. VBA is an excellent solution for automating a manual process. In general, if a person can perform a task manually via a sequence of pre-defined steps then VBA can do it automatically, faster, and with less chance of mistakes for something done many times. We’d be happy set up a call to discuss your needs further and see what could be automated with VBA. If that’s of interest, please use the contact button at the top of the page and mention my name in the form.

PP does not seem to have the record macro feature. To write vba code in PP by someone who only worked with vba in excel, would require some prior knowledge. Is there a summary of the most common objects, methods etc to refer to?

Hi Reef. You’re correct that there’s no VBA macro recording feature in newer versions of PowerPoint. The best place to start learning is by purchasing a book (there’s one called “Mastering VBA for Microsoft Office 365” on Amazon or reading the extremely exciting Object Model documentation from Microsoft: https://docs.microsoft.com/en-us/office/vba/api/overview/powerpoint/object-model

Hi Greeting I had made a game in power point using VBA codes. At last it generate a report every time a candidate conduct the game . My requirement is to generate result in same excel sheet after conducting the game. Like Row 1 player 1 result Row 2 player 2 result I need your help Regards

Hi Asheesh. It’s possible to use VBA to get PowerPoint to “talk” to Excel (and other Office apps) but it’s a bit complicated to mention in a comment here. We’d be happy to help if you’d like a quote or if you want to try yourself you could start with this: Set oXL = CreateObject(“Excel.Application”) and have a look at some online examples. I’d also recommend the book “Mastering VBA for Microsoft Office 365” available from Amazon.

If there are two colors of font in the textFrame, how to change the font of one color through VBA?

Hi Bruce. You could either iterate through the Characters collection of the TextRange2 object or the Runs collection which returns all of the TextRanges with the same style. Example: ActiveWindow.Selection.ShapeRange(1).TextFrame2.TextRange.Runs(1).Font.Fill.ForeColor.RGB

Hi – can you help, please?

How can I change the font color and size of the message box? What code will work and where will I put it? Creating an interactive game in powerpoint. Thank you!

—– Sub Correct() Points.Caption = (Points.Caption) + 10 Output = MsgBox(“Your answer is correct, well done!”, vbOKOnly, “Correct Answer”) ActivePresentation.SlideShowWindow.View.Next End Sub

Sub Incorrect() Points.Caption = (Points.Caption) – 5 Output = MsgBox(“Your answer is incorrect.”, vbOKOnly, “Wrong Answer”) ActivePresentation.SlideShowWindow.View.Next End Sub

Sub Reset() SlideLayout.Points.Caption = 0 ActivePresentation.SlideShowWindow.View.Exit End Sub ———-

Thanks for your explanation.

Hi Jamie, Is there any way to keep my macro save in a file so I can utilize on any other PPTs equivalent as.normal.dotm for Word, .xlam(add-in) for Excel.

Hi Anurag. Thanks for the question and Happy New Year! The best way to do this would be to export your project as a ppam and activate it as an add-in via the PowerPoint add-ins UI. Save your ppam in %AppData%\Microsoft\AddIns and then in the Windows PowerPoint Developer tab, click PowerPoint Add-Ins and add your ppam from there. If you’re not code-signing your VBA project, you may need to adjust Trust Centre settings. You could optionally build an EXE/MSI installer package for Windows and PKG for macOS, although that is a more complex topic.

Join the BrightCarbon mailing list for monthly invites and resources

We’d been badly let down and got hold of BrightCarbon on a Friday afternoon – with a Monday deadline! They were reassuring, professional, easy to work with. They listened and delivered great visuals – now adopted across the board. Matt Dean byrne∙dean

vba powerpoint exit presentation mode

  • VBA / Excel / Access / Word
  • Application
  • Data Type Functions
  • Date Functions
  • Language Basics
  • Math Functions
  • String Functions
  • Windows API

Exiting the Slide Show : Slide Show « PowerPoint « VBA / Excel / Access / Word

MrExcel Message Board

  • Search forums
  • Board Rules

Follow along with the video below to see how to install our site as a web app on your home screen.

Note: This feature may not be available in some browsers.

  • If you would like to post, please check out the MrExcel Message Board FAQ and register here . If you forgot your password, you can reset your password .
  • Question Forums
  • General Discussion & Other Applications

Excel VBA Open PowerPoint into slideshow mode

  • Thread starter gmooney
  • Start date Feb 20, 2019
  • Tags mode open ppt set slideshow

gmooney

Active Member

  • Feb 20, 2019

Taking this code I would like to add the ability to have the PPT automatically open in slideshow mode: Private Sub MonthlyToplinePPT() ' Opens Presentation.pptx Dim PPT As Object Set PPT = CreateObject("PowerPoint.Application") PPT.Visible = True PPT.Presentations.Open Filename:="C:\Topline\Topline Writeup.pptx" Set PPT = Nothing End Sub Any thoughts?  

Excel Facts

Well-known member.

This looks to be working: Code: Private Sub MonthlyToplinePPT() ' Opens Presentation.pptx Dim PPT As Object Set PPT = CreateObject("PowerPoint.Application") PPT.Visible = True PPT.Presentations.Open Filename:="[COLOR=#333333]C:\Topline\Topline Writeup.pptx[/COLOR]" With PPT.ActivePresentation.SlideShowSettings .ShowType = ppShowSpeaker .Run.View.AcceleratorsEnabled = False End With Set PPT = Nothing End Sub  

  • Feb 21, 2019

Thanks mrshl9898....worked perfectly!  

Similar threads

  • picklefactory
  • Jun 7, 2023
  • Dec 6, 2023
  • Green_Square_Window
  • Feb 6, 2024
  • Mar 30, 2023

NdNoviceHlp

  • Feb 27, 2023

Forum statistics

Share this page.

vba powerpoint exit presentation mode

We've detected that you are using an adblocker.

Which adblocker are you using.

AdBlock

Disable AdBlock

vba powerpoint exit presentation mode

Disable AdBlock Plus

vba powerpoint exit presentation mode

Disable uBlock Origin

vba powerpoint exit presentation mode

Disable uBlock

vba powerpoint exit presentation mode

  • Site Search Search Posts Find A Forum Thread Number Threads by Name Search FAQs
  • ENGINEERING.com
  • Eng-Tips Forums
  • Tek-Tips Forums

Engineering forums for professionals

Join Eng-Tips ® Today!

Join your peers on the Internet's largest technical engineering professional community. It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

  • Notification Of Responses To Questions
  • Favorite Forums One Click Access
  • Keyword Search Of All Posts, And More...

Register now while it's still free!

Already a member? Close this window and log in.

Join Us               Close

How to Enable Macros in PowerPoint: A Step-by-Step Guide

  • Recent Posts
  • Print an Outline in PowerPoint: A Step-by-Step Guide - May 24, 2024
  • PowerPoint Presentation Images: Do You Need to Cite Stock Photos? - May 24, 2024
  • Grouping Pictures in PowerPoint: A Step-by-Step Guide - May 24, 2024

Enabling macros in PowerPoint is an essential function that allows users to automate tasks and increase efficiency. Macros are a set of instructions that automate repetitive tasks, saving valuable time and effort. However, the process of enabling macros in PowerPoint can be confusing for some users. In this article, I will provide step-by-step instructions on how to enable macros in PowerPoint and ensure security while doing so.

A computer screen with a PowerPoint window open. A cursor hovers over the "File" tab, then clicks "Options." In the Options window, the cursor selects "Trust Center" and then "Trust Center Settings." Finally, the cursor clicks on

To begin, you need to access the macro settings within PowerPoint. Click on the “File” tab and select “Options” from the drop-down menu. In the “PowerPoint Options” window, select “Trust Center” from the left-hand menu, and then click on the “Trust Center Settings” button. From here, you can access the “Macro Settings” option and adjust the security settings to enable macros.

It’s important to note that enabling macros can pose a security risk, as they can be used to execute malicious code. Therefore, it’s crucial to follow the steps carefully and ensure that you trust the source of the macro before enabling it. By following these steps, you can safely enable macros in PowerPoint and increase your productivity.

JUMP TO TOPIC

Understanding Macro Security Settings

Steps to enable macros, creating and editing macros, vba project and code management, saving and sharing presentations with macros, security considerations, utilizing macros for interactivity and efficiency, best practices for macro usage, enabling macros in powerpoint.

A computer screen with a PowerPoint window open, displaying the "Enable Macros" prompt. A mouse cursor hovers over the "Enable Macros" button

Enabling macros in PowerPoint is a straightforward process that requires a few simple steps. Before enabling macros, it is important to understand the security settings that come with it.

Macros are scripts that automate repetitive tasks in PowerPoint. However, they can also be used as a tool for cybercriminals to infect your computer with malware. For this reason, Microsoft has implemented several security measures to protect users.

By default, PowerPoint disables all macros to prevent potential security risks. However, you can adjust the security settings to enable macros. There are three levels of macro security settings in PowerPoint:

  • Disable all macros without notification
  • Disable all macros with notification
  • Enable all macros (not recommended)

The first option disables all macros without any notification, while the second option disables all macros but prompts the user with a notification before enabling any macros. The third option enables all macros without any notification, which is not recommended due to the potential security risks.

To enable macros in PowerPoint, follow these steps:

  • Open PowerPoint and click on the “File” tab.
  • Select “Options” from the left-hand pane.
  • Click on “Trust Center” and then click on “Trust Center Settings.”
  • In the Trust Center window, click on “Macro Settings.”
  • Select the option that best suits your needs. For example, if you want to enable all macros with notification, select “Disable all macros with notification.”
  • Click “OK” to save your changes and exit the Trust Center window.

Once you have enabled macros, you can access them through the Developer tab. To access the Developer tab, click on “File” and then select “Options.” In the Options window, click on “Customize Ribbon” and check the box next to “Developer.” Click “OK” to save your changes.

From the Developer tab, you can access the Macro dialog box to create, edit, and run macros. Keep in mind that enabling macros can be a potential security risk, so make sure to only enable them from trusted sources.

Enabling macros in PowerPoint can be a useful tool for automating repetitive tasks. However, it is important to understand the potential security risks and adjust the security settings accordingly. By following these simple steps, you can enable macros in PowerPoint and use them to enhance your productivity.

Working with VBA in PowerPoint

Visual Basic for Applications (VBA) is a programming language that allows users to automate tasks and create interactive presentations in PowerPoint. As a developer, the VBA editor is an essential tool for creating and editing macros. In this section, I will discuss how to create and edit macros in PowerPoint using the VBA editor and best practices for managing VBA projects and code.

To create a macro in PowerPoint, you must first enable the Developer tab. Once enabled, you can access the VBA editor by clicking on the Developer tab and selecting Visual Basic. This will open the VBA editor, where you can create and edit macros.

When creating macros, it is important to follow best practices to ensure that your code is efficient and easy to understand. One of the best practices is to use variables to store data and avoid hard-coding values. This makes your code easier to read and maintain.

To edit an existing macro, you can simply open the VBA editor and select the macro you want to edit. You can then modify the code to add new functionality or improve existing code.

Managing VBA projects and code is essential for ensuring that your macros are secure and efficient. One of the best practices for managing VBA projects is to use the VBA Project object model. This allows you to access and modify the properties of your VBA project, such as modules and forms.

Another important aspect of VBA project management is macro security. PowerPoint has built-in security features that allow you to enable or disable macros and set macro security levels. It is important to only enable macros from trusted publishers and avoid running potentially dangerous code.

When working with VBA code, it is important to use proper indentation and comments to make your code more readable. This makes it easier for other developers to understand your code and make modifications.

In summary, VBA is a powerful programming language that can be used to automate tasks and create interactive presentations in PowerPoint. By following best practices for creating and editing macros and managing VBA projects and code, you can create secure and efficient macros that enhance your presentations.

Macro-Enabled Presentations

As the name suggests, a macro-enabled presentation is a PowerPoint document that has macros embedded within it. Macros are small programs that automate repetitive tasks and enhance the functionality of the presentation. If you’ve created a macro in PowerPoint, you’ll need to enable macros in order to use it.

When you save a macro-enabled presentation, it’s important to remember that it may contain potentially dangerous code that can run on your computer. Therefore, it’s essential to save the document in a trusted location and only share it with people you trust. You can save the document as a PowerPoint Macro-Enabled Presentation (.pptm) file to ensure that the macros are saved along with the presentation.

Enabling macros in PowerPoint can be a security risk, as they can potentially contain viruses or malware. When you open a macro-enabled presentation, PowerPoint will display a security warning asking you to enable or disable the macros. If you trust the document and want to use the macros, you can click “Enable Content” to allow the macros to run.

It’s important to note that enabling macros in PowerPoint can pose security risks. Therefore, it’s recommended that you only enable macros in presentations from trusted sources. You can also adjust the macro security settings in PowerPoint to ensure that macros are only enabled in trusted documents or locations.

To adjust the macro security settings in PowerPoint, follow these steps:

  • Click on the “File” tab in the Ribbon.
  • Click on “Options” to open the PowerPoint Options dialog box.
  • Click on “Trust Center” in the left-hand pane.
  • Click on “Trust Center Settings” to open the Trust Center dialog box.
  • Click on “Macro Settings” in the left-hand pane.
  • Choose the security level that you want to use for macros. You can choose to disable all macros, enable all macros, or enable only digitally signed macros.

By following these steps, you can ensure that your PowerPoint presentations are secure and that macros are only enabled in trusted documents or locations.

Advanced PowerPoint Macro Techniques

PowerPoint macros can be used to add interactivity and efficiency to presentations. By using macros, you can automate repetitive tasks, such as formatting and aligning shapes, and create interactive elements, such as buttons and menus.

One way to use macros for interactivity is to create custom buttons that execute specific actions when clicked. For example, you can create a button that navigates to a specific slide, or a button that plays a video. To create a button, you can use the “Shapes” tool in PowerPoint and assign a macro to it.

Another way to use macros for efficiency is to automate repetitive tasks. For example, if you need to move a large number of shapes to a specific location, you can create a macro that does it for you. By automating these tasks, you can save time and focus on other aspects of your presentation.

While macros can be powerful tools, it’s important to use them responsibly to maintain security and efficiency. Here are some best practices for using macros in PowerPoint:

  • Digitally sign your macros: Digitally signed macros are less likely to be blocked by security settings. To digitally sign a macro, you need a digital certificate from a trusted authority.
  • Disable all macros except digitally signed macros: This setting can be found in the “Trust Center” options in PowerPoint. By disabling all macros except digitally signed macros, you can prevent malicious macros from running on your computer.
  • Disable all macros without notification: This setting can also be found in the “Trust Center” options in PowerPoint. By disabling all macros without notification, you can prevent macros from running automatically without your knowledge.
  • Take advantage of subscription benefits: If you have a Microsoft 365 subscription, you can access training courses and get expert help with macros and other features in PowerPoint, Excel, and Word.
  • Secure your device: Make sure your device is up-to-date with the latest security updates and antivirus software to prevent malware and other security threats.
  • Use the “PowerPoint Options” and “Quick Access Toolbar” features to customize your PowerPoint environment and make it more efficient.
  • Use the “Slide Master” and “Templates” features to create consistent designs and layouts throughout your presentation.
  • Use the “ActiveWindow.Selection” and “ShapeRange” objects to manipulate shapes and other objects in your presentation.
  • Use interactive elements, such as buttons and menus, to make your presentation more engaging and interactive.

By following these best practices, you can use macros in PowerPoint safely and efficiently. Remember to always test your macros before using them in a live presentation, and to keep your macros organized and well-documented for future use.

Leave a Comment Cancel reply

Save my name, email, and website in this browser for the next time I comment.

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Application.PresentationOpen event (PowerPoint)

  • 6 contributors

Occurs after an existing presentation is opened, as it is added to the Presentations collection.

expression . PresentationOpen ( _Pres_ )

expression An expression that returns an Application object.

For information about using events with the Application object, see How to: Use Events with the Application Object .

If your Visual Studio solution includes the Microsoft.Office.Interop.PowerPoint reference, this event maps to the following types:

Microsoft.Office.Interop.PowerPoint.EApplication_PresentationOpenEventHandler (the PresentationOpen delegate.)

Microsoft.Office.Interop.PowerPoint.EApplication_Event.PresentationOpen (the PresentationOpen event.)

This example modifies the background color for color scheme three, applies the modified color scheme to the presentation that was just opened, and displays the presentation in slide view.

Application Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

Was this page helpful?

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback .

Submit and view feedback for

Additional resources

IMAGES

  1. How to use VBA in PowerPoint: A beginner's guide

    vba powerpoint exit presentation mode

  2. VBA PowerPoint

    vba powerpoint exit presentation mode

  3. How to use VBA in PowerPoint: A beginner's guide

    vba powerpoint exit presentation mode

  4. How to use VBA in PowerPoint: A beginner's guide

    vba powerpoint exit presentation mode

  5. PowerPoint Automation using VBA. Complete professional course for free

    vba powerpoint exit presentation mode

  6. VBA PowerPoint

    vba powerpoint exit presentation mode

VIDEO

  1. PPT Automation VBA

  2. VBA Final presentation

  3. Mason Senior Exit Presentation 20240425

  4. Compare 3 Excel Drop Down List Types for Data Entry

  5. Microsoft PowerPoint: How to Change the Exit Animation Direction

  6. How to copy a text or shape in a slide to all slides of Powerpoint using Macro

COMMENTS

  1. Presentation.Close method (PowerPoint)

    Closes the specified presentation. Syntax. expression.Close. expression A variable that represents a Presentation object. Remarks. When you use this method, PowerPoint will close an open presentation without prompting the user to save their work. To prevent the loss of work, use the Save method or the SaveAs method before you use the Close ...

  2. vba

    1. Using Insert>Action>Run macro, assign this to a shape, then copy the shape to each slide. The shape can be the same color as the background if you want it to be unobstrusive: Sub ExitSlide() ActivePresentation.SlideShowWindow.View.Exit. End Sub. answered Aug 20, 2020 at 18:22. John Korchok. 4,864 2 12 22.

  3. VBA to close the current PowerPoint presentation while opening another

    For anyone that needs a 'SWAP' of PowerPoint .ppsm files, this code will do the trick: Sub CloseThisPPT_OpenAnother (ByVal OtherPPTFileName As String) Dim pptNew As Presentation. Dim pptApp As PowerPoint.Application. Set pptApp = CreateObject ("PowerPoint.Application")

  4. How to come out of Presentation Mode without closing a powerpoint

    Right-click & select End Show from the contextual menu. Press Command+. (Command+period) Press the Hyphen (-) key. When in Presenter View, all but the Hyphen method should return to Normal View, as well. In Presenter view, however, there is an End Show button ⊗ in the upper left corner of the window. If neither of those methods is working for ...

  5. PowerPoint VBA

    1. I know I could do the following to run code when the slide is changed in presentation mode -. Sub OnSlideShowPageChange() Dim i As Integer. i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition. If i <> 1 Then Exit Sub. 'Code that should happen when slide changes goes here.

  6. How to stop PowerPoint from exiting presentation mode after the last

    Another option: Remove the End Show with Black slide checkmark as described above. Then on the actual last slide add a full-slide rectangle, no-outline, 99% transparent fill. It's now invisible. Add a Go To Slide link on the rectangle and have it link to the slide itself.

  7. PowerPoint VBA Macro Examples & Tutorial

    Create PowerPoint Macro. This is a simple example of a PowerPoint VBA Macro: Sub SavePresentationAsPDF() Dim pptName As String Dim PDFName As String ' Save PowerPoint as PDF. pptName = ActivePresentation.FullName. ' Replace PowerPoint file extension in the name to PDF.

  8. How to use VBA in PowerPoint: A beginner's guide

    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): *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 ...

  9. Exiting the Slide Show : Slide Show « PowerPoint « VBA ...

    Show slides 4 through 8 in the presentation: 7. To start running a custom show: 8. Moving from Slide to Slide: 9. To display the first slide in the presentation, use the First method. 10. To display the last slide, use the Last method: 11. To display the next slide, use the Next method. 12. To display the previous slide, use the Previous method ...

  10. Excel VBA Open PowerPoint into slideshow mode

    Taking this code I would like to add the ability to have the PPT automatically open in slideshow mode: Private Sub MonthlyToplinePPT () ' Opens Presentation.pptx. Dim PPT As Object. Set PPT = CreateObject ("PowerPoint.Application") PPT.Visible = True. PPT.Presentations.Open Filename:="C:\Topline\Topline Writeup.pptx". Set PPT = Nothing.

  11. turning off "design mode" in powerpoint

    Here's the deal. I turned on the control tool box and inserted a button on my powerpoint slide that I'd like to use to laucn a macro. I double clicked the button and linked to my macro (no problem). Now I want to exit design mode back into run mode, so that when I click on the button it lauches the macro (rather than bringing up the properties).

  12. How to Enable Macros in PowerPoint: A Step-by-Step Guide

    To enable macros in PowerPoint, follow these steps: Open PowerPoint and click on the "File" tab. Select "Options" from the left-hand pane. Click on "Trust Center" and then click on "Trust Center Settings.". In the Trust Center window, click on "Macro Settings.". Select the option that best suits your needs.

  13. Macro for disabling ESC key in PowerPoint slide show

    ESC key is still working even after running it by Macro Window or clicking action button for "Run macro" during show. Macros are set to Always Enabled ( Lowest security mode ) in Office Options and presentation is saved as (.ppsm), so macro-enabled format. Here is my full modified code: vkCode As Long.

  14. Application.PresentationOpen event (PowerPoint)

    For information about using events with the Application object, see How to: Use Events with the Application Object. If your Visual Studio solution includes the Microsoft.Office.Interop.PowerPoint reference, this event maps to the following types: Microsoft.Office.Interop.PowerPoint.EApplication_PresentationOpenEventHandler (the PresentationOpen ...

  15. Is it possible to jump to a specific PowerPoint slide using VBA?

    Here is some code to rename the current slide. Sub ChangeSlideName() Dim NewName As String. Dim ActiveSlide As Slide. Set ActiveSlide = ActiveWindow.View.Slide. NewName = InputBox("Enter new slide name for slide " & _. ActiveSlide.SlideIndex, "New Slide Name", ActiveSlide.Name) If NewName = "" Then.