You have a blank PPT file saved in Drive (D:).
Step 1 – Launch the Developer Tab
- Right-click the ribbon.
- Select Customize the Ribbon.
- In Excel Options, go to Customize Ribbon.
- Check Developer in Main Tabs.
- Click OK.
The Developer tab will be displayed on the ribbon.
Step 2 – Create a CommandButton
- Go to the Developer tab.
- Click Insert in Controls.
- Select CommandButton in ActiveX Controls.
- Drag your mouse and place the button in the worksheet.
- Click it.
The Visual Basic Editor will be displayed.
Step 3 – Enable the PowerPoint Object Model
- Go to the Tools tab.
- Click References.
- In the References – VBAProject window, check Microsoft PowerPoint 16.0 Object Library.
- Click OK.
Step 4 – Use a VBA Code
- Enter the following VBA code:
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
Step 5 – Final Output
- Go back to your worksheet and click CommandButton1.
This will open the existing file.
How to Create a PowerPoint File with Excel VBA
STEPS:
- Go to the Developer tab.
- Click Visual Basic in Code to open the Visual Basic Editor. You can also press Alt + F11.
- Alternatively, right-click the worksheet and go to View Code.
- Select Module in Insert.
- Enter the VBA code 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
- Run the code by clicking RunSub or pressing F5.
This will create a PowerPoint slide.
Read More: [Solved] Embedded Excel in PowerPoint Not Showing All Data
Download Practice Workbook
Download the workbook and practice.
Related Articles
- How to Link PowerPoint to Excel for Dynamic Data Updates
- How to Embed an Excel File in PowerPoint
- [Fixed!] Problems with Embedded Excel Files in PowerPoint
- How to Link Excel Sheets to PowerPoint
<< Go Back to Excel to PowerPoint | Export Data from Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!