Disclosure: This post may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.

How to Open Existing PowerPoint File from Excel VBA

We can systematize the tasks we do for PowerPoint using VBA. VBA’s ability to make references to other Microsoft products like “Microsoft Word” and “Microsoft PowerPoint” is one of its best features. Typically, Excel reports are produced first, followed by PowerPoint slides. In this article, we will demonstrate the instructions to open an existing PowerPoint file from excel VBA.


Download Practice Workbook

You can download the workbook and practice with them.


Step-by-Step Procedures to Open Existing PowerPoint File from Excel VBA

The Visual Basic for Applications (VBA) editor in Excel is an extremely effective tool. It enables you to create and change unique Excel automation scripts. We can write code as per our needs. With Excel VBA, users can easily use the code which acts as an excel menu from the ribbon. Suppose, we have a blank PPT file saved on Drive (D:). To use the VBA code to open an existing PowerPoint file, let’s follow the steps down.

open existing powerpoint from excel vba


Step 1: Launch Developer Tab

First, we need to Launch the developer tab on excel. To enable this feature we need to follow the following steps.

  • To begin with, right-click on the ribbon.
  • Then, select Customize the Ribbon.

open existing powerpoint from excel vba

  • Thus, the Excel Options dialog box will appear.
  • Further, go to Customize Ribbon.
  • Checkmark the Developer tab under Main Tabs.
  • Finally, click on the OK button.

  • Thus, the Developer tab will appear in the ribbon.

open existing powerpoint from excel vba


Step 2: Create CommandButton

A macro or process can be run or executed using the CommandButton. Whenever a user clicks on a command button, it executes a task or operation. The Spreadsheet supports the usage of the Command Button.

  • Go to the Developer tab from the ribbon.
  • Further, click on the Insert drop-down menu, under the Controls group.
  • Then, select CommandButton from ActiveX Controls.

  • Drag your mouse and place the button as you want it and click on it.

  • This will automatically take you to the Visual Basic Editor.


Step 3: Enable PowerPoint Object Model

At this step, we need to go through PowerPoint’s security settings and activate all Macros before you can utilize VBA code or snippets to operate in PowerPoint. After that, we may utilize the MS PowerPoint VBA reference for Macros.

  • Go to the Tools tab from the ribbon.
  • Then, click on References.

  • Thus, the References – VBAProject window will be displayed.
  • Further, scroll down a bit and check mark Microsoft PowerPoint 16.0 Object Library.
  • Lastly, clicking on the OK button will finish the step.

open existing powerpoint from excel vba

Read More: How to Embed an Excel File in PowerPoint (5 Easy Ways)


Similar Readings


Step 4: Insert VBA Code

At this step, we will write our code in the Visual Basic Editor.

  • Copy and paste the following VBA code shown below.

VBA Code:

Private Sub CommandButton1_Click()
Dim PwrApp As PowerPoint.Application
Dim PwrPre As PowerPoint.Presentation
Dim PwrSd As PowerPoint.Slide
Set PwrApp = New PowerPoint.Application
Set PwrPre = PwrApp.Presentations.Open("D:\Presentation1.pptx")
End Sub

open existing powerpoint from excel vba

Note: You don’t need to change the code. All you can do is just change the file path as per your requirements.

Read More: How to Perform Excel to PowerPoint Automation (With Easy Steps)


Step 5: Final Output

To see the final result after using the VBA code. Let’s do the following.

  • Go back to your worksheet and click on CommandButton1.

  • This will open the existing file.


How to Create PowerPoint File with Excel VBA

Now, we will demonstrate how to use VBA source code to construct a PowerPoint presentation from an Excel spreadsheet if you devote a lot of time creating Powerpoint slides.

STEPS:

  • Firstly, go to the Developer tab from the ribbon.
  • Secondly, click on Visual Basic from the Code category to open the Visual Basic Editor. Or press Alt + F11 to open the Visual Basic Editor.

  • Instead of doing this, you can just right-click on your worksheet and go to View Code. This will also take you to Visual Basic Editor.

open existing powerpoint from excel vba

  • This will appear in the Visual Basic Editor where we write our code.
  • Thirdly, click on Module from the Insert drop-down menu bar.

open existing powerpoint from excel vba

  • This will create a Module in your workbook.
  • And, copy and paste the VBA code shown below.

VBA Code:

Sub Create_PPT()
    Dim PwrApp As PowerPoint.Application
    Dim PwrPre As PowerPoint.Presentation
    Dim PwrSde As PowerPoint.Slide
    Dim PwrShpe As PowerPoint.Shape
    Dim PwrChrt As Excel.ChartObject
    Set PwrApp = New PowerPoint.Application
    PwrApp.Visible = msoCTrue
    PwrApp.WindowState = ppWindowMaximized
    Set PwrPre = PwrApp.Presentations.Add
    Set PwrSd = PwrPre.Slides.Add(1, ppLayoutTitleOnly)
End Sub
  • After that, run the code by clicking on the RubSub button or pressing the keyboard shortcut F5.

open existing powerpoint from excel vba

  • This will create a PowerPoint slide.

Read More: Automatically Create PowerPoint Slides from Excel (3 Easy Ways)


Conclusion

The above procedures will assist you to Open Existing Powerpoint File from Excel VBA. Hope this will help you! Please let us know in the comment section if you have any questions, suggestions, or feedback. Or you can glance at our other articles in the ExcelDemy.com blog!


Related Articles

Sabrina Ayon

Sabrina Ayon

Hi there! This is Sabrina Ayon. I'm really excited to welcome you to my profile. Currently, I'm working in SOFTEKO as a Team Leader. I'm a graduate in BSc in Computer Science and Engineering from United International University. I love working with computers and solving problems. I’ve always been interested in research and development. Here I post articles related to Microsoft Excel. Hoped this may help you. Thank you.

We will be happy to hear your thoughts

Leave a reply

ExcelDemy
Logo