• Skip to primary navigation
  • Skip to main content
  • Skip to footer
WallStreetMojo

Wallstreet Mojo

Wallstreet Mojo

MENUMENU
  • Resources
        • Excel

          • Excel Functions
          • Excel Tools
          • Excel Tips
        • Excel
        • Financial Functions Excel

          • NPV in Excel
          • IRR in excel
          • PV in Excel
        • Financial-Functions-Excel
        • Lookup Functions Excel

          • VLOOKUP
          • HLOOKUP
          • Index Function
        • Lookup-Functions-in-Excel
        • Excel Charts

          • Pareto Chart in Excel
          • Gannt Chart in Excel
          • Waterfall Chart in Excel
        • Excel-Charts
        • VBA

          • VBA Left Function
          • VBA Paste Special
          • VBA Worksheet Function
        • VBA
        • Others

          • Resources (A to Z)
          • Financial Modeling
          • Equity Research
          • Private Equity
          • Corporate Finance
          • Financial Statement Analysis
  • Free Courses
  • All Courses
        • Certification Courses

          Excel Course certificate
        • Excel VBA All in One Bundle

          Excel-VBA-Certification-Course
        • Excel Data Analysis Course

          Excel-Data-Analysis-Course
        • VBA Macros Course

          VBA-Training-Course
        • Others

          • Basic Excel Training
          • Advanced Excel Course
          • Tableau Certification Course
          • Excel for Finance Course

          • Excel for Marketers Course
          • Excel for HR Managers
          • Excel for Power Users
          • View All
  • Excel VBA All in One Bundle
  • Login

VBA PowerPoint

Home » VBA » VBA Tips » VBA PowerPoint

By Sharmila Reddy Leave a Comment

VBA PowerPoint

In PowerPoint, we can also use VBA codes to automate the work we do for PowerPoint, but first in order to use VBA code or snippets to work in VBA first work through the security options in PowerPoint to enable all macros and then we use PowerPoint VBA reference for macros in MS PowerPoint.

PowerPoint in Excel VBA

The beauty of VBA is that we can reference other Microsoft products like “Microsoft Word” and “Microsoft PowerPoint”. We usually create reports in excel and then create PowerPoint presentations. All the excel users usually spend a considerable amount of time to prepare the presentation from excel data and reports. If you are spending a considerable amount of time to prepare powerpoint presentations this article will show you how to create power point presentation from excel itself using VBA Coding.

How to Create a PowerPoint Presentation from Excel VBA?

We can create power point presentation in two way one us using “Early Binding” and another one is using “Late Binding”.

In this article, we will show you how to create a power point presentation by using “Early Binding” technique in VBA.

To do this first we need to reference the PowerPoint object model in visual basic editor.

Step 1: Open VBA Editor and then, Go to Tools and References.

VBA Powerpoint Step 1

Step 2: Now you will see all the references to the VBA Project. Scroll down and Select “Microsoft PowerPoint 15.0 Object Library”.

VBA Powerpoint Step 2

Step 3: Click on Ok. Now we can access PowerPoint from excel.

VBA Powerpoint Step 3

Usually, from excel we prepare presentations based on charts and interpretation of the charts. So for this purpose, I have created some simple charts and interpretation in the same worksheet.

Popular Course in this category
Cyber Monday Sale
VBA Training (3 Courses, 12+ Projects) 3 Courses | 12 Hands-on Projects | 43+ Hours | Full Lifetime Access | Certificate of Completion
4.6 (247 ratings)
Course Price

View Course

Related Courses

VBA Powerpoint Step 3.1

VBA Powerpoint Step 3.2

VBA Powerpoint Step 3.3

Step 4: Start the VBA subprocedure. Now to access VBA PowerPoint we have already enabled PowerPoint object model in the earlier steps, now to access this we need to declare the variable as PowerPoint.Application.

Code:

Sub PPT_Example()
   
    Dim PPApp As PowerPoint.Application
End Sub

VBA Powerpoint Step 4

Step 5: Not to add the presentation to the VBA PowerPoint we need to declare a variable as PowerPoint.Presentation.

Code:

 Dim PPPresentation As PowerPoint.Presentation

VBA Powerpoint Step 5

Step 6: After adding the presentation to the PowerPoint we need to add Slide. To declare the variable as PowerPoint.Slide

Code:

Dim PPSlide As PowerPoint.Slide

VBA Powerpoint Step 6

Step 7: Once the slide is added to the PowerPoint we need to make use of shapes in the PowerPoint i.e. text boxes. To declare a variable as PowerPoint.Shape

Code:

Dim  PPShape As  PowerPoint.Shape

VBA Powerpoint Step 7

Step 8: Now to access all the charts in the worksheet we need to declare the variable as Excel.ChartObjects.

Code:

Dim PPCharts As Excel.ChartObject

VBA Powerpoint Step 8

Ok, to start off the proceedings these variables are enough.

Step 9: Now we need to launch the PowerPoint from excel. Since PowerPoint is an external object we need to set this as a new power point.

Code:

Set PPApp = New PowerPoint.Application

Pp Step 9

This will launch the new PowerPoint from excel.

Step 10: Now the variable PPApp is equal to the PowerPoint we have launched. Now make this PowerPoint visible and maximize the window.

 Code:

PPApp.Visible = msoCTrue
PPApp.WindowState = ppWindowMaximized

PP Step 10

At this moment just run the code using F5 key or manually, you should see PowerPoint app launched like the below one.

Pp Step 10.1

Step 11: Now we need to add a presentation to the PowerPoint app we have launched.

Code:

Set PPPresentation = PPApp.Presentations.Add

Pp Step 11

Now we should see the PowerPoint presentation like this.

PP Step 11.1

Step 12: After adding the presentation we need to add a slide.

Code:

Set PPSlide = PPPresentation.Slides.Add(1,  ppLayoutTitleOnly)

Pp Step 12

Now this will add the title slide PowerPoint presentation like the below.

PP Step 12.1

Step 13:  Now we have more than one chart in the worksheet we need to loop through each chart and paste in the presentation. Below is the code to copy and paste the chart as well as interpretation.

Below is the complete code for you.

Sub PPT_Example()

    Dim PPApp As PowerPoint.Application
    Dim PPPresentation As PowerPoint.Presentation
    Dim PPSlide  As PowerPoint.Slide
    Dim PPShape As PowerPoint.Shape
    Dim PPCharts As Excel.ChartObject

    Set PPApp = New PowerPoint.Application

    PPApp.Visible = msoCTrue
    PPApp.WindowState = ppWindowMaximized

    'Add Presentation
     Set PPPresentation = PPApp.Presentations.Add

     'Loop through each chart in the Excel and paste into the PowerPoint
     For Each PPCharts In ActiveSheet.ChartObjects
       PPApp.ActivePresentation.Slides.Add PPApp.ActivePresentation.Slides.Count + 1, ppLayoutText
       PPApp.ActiveWindow.View.GotoSlide PPApp.ActivePresentation.Slides.Count
       Set PPSlide = PPApp.ActivePresentation.Slides(PPApp.ActivePresentation.Slides.Count)

    'Copy the chart and paste in Powerpoint
     PPCharts.Select
     ActiveChart.ChartArea.Copy
     PPSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select

    'Add heading to the slide
     PPSlide.Shapes(1).TextFrame.TextRange.Text = PPCharts.Chart.ChartTitle.Text

    'Allignment of the chart
     PPApp.ActiveWindow.Selection.ShapeRange.Left = 15
     PPApp.ActiveWindow.Selection.ShapeRange.Top = 125

     PPSlide.Shapes(2).Width = 200
     PPSlide.Shapes(2).Left = 505

     'Add interpretation
        If InStr(PPSlide.Shapes(1).TextFrame.TextRange.Text, "Region") Then
           PPSlide.Shapes(2).TextFrame.TextRange.Text = Range("K2").Value & vbNewLine
           PPSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("K3").Value & vbNewLine)
     'Else if the chart is the "Renewable" consumption chart, then enter the appropriate comments
         ElseIf InStr(PPSlide.Shapes(1).TextFrame.TextRange.Text, "Month") Then
           PPSlide.Shapes(2).TextFrame.TextRange.Text = Range("K20").Value & vbNewLine
           PPSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("K21").Value & vbNewLine)
           PPSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("K22").Value & vbNewLine)
      End If

   'Now let's change the font size of the callouts box
      PPSlide.Shapes(2).TextFrame.TextRange.Font.Size = 16

Next PPCharts

End Sub

VBA Powerpoint Step 13

You can download this Excel VBA PowerPoint template here – VBA PowerPoint Template

Recommended Articles

This has been a guide to VBA PowerPoint. Here we learn how to create a PowerPoint presentation by using “Early Binding” technique in VBA Code along with examples and a downloadable template. Below are some useful excel articles related to VBA –

  • VBA Selection
  • VBA ByRef Function Argument
  • Delete Files using VBA
  • VBA Charts
  • VBA Val Function
  • VBA OverFlow Error 6
  • VBA ISNULL()
  • Create VBA Pivot Table
1 Shares
Share
Tweet
Share
VBA Training (3 Courses, 12+ Projects)
  • 3 Courses
  • 12 Hands-on Projects
  • 43+ Hours
  • Full Lifetime Access
  • Certificate of Completion
LEARN MORE >>

Filed Under: VBA, VBA Tips

Reader Interactions
Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Footer
COMPANY
About
Reviews
Blog
Contact
Privacy
Terms of Service
FREE COURSES
Free Finance Online Course
Free Accounting Online Course
Free Online Excel Course
Free VBA Course
Free Investment Banking Course
Free Financial Modeling Course
Free Ratio Analysis Course

CERTIFICATION COURSES
All Courses
Financial Analyst All in One Course
Investment Banking Course
Financial Modeling Course
Private Equity Course
Business Valuation Course
Equity Research Course
CFA Level 1 Course
CFA Level 2 Course
Venture Capital Course
Microsoft Excel Course
VBA Macros Course
Accounting Course
Advanced Excel Course
Fixed Income Course
RESOURCES
Investment Banking
Financial Modeling
Equity Research
Private Equity
Excel
Books
Certifications
Accounting
Asset Management
Risk Management

Copyright © 2019. CFA Institute Does Not Endorse, Promote, Or Warrant The Accuracy Or Quality Of WallStreetMojo. CFA® And Chartered Financial Analyst® Are Registered Trademarks Owned By CFA Institute.
Return to top

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.

Free Investment Banking Course

IB Excel Templates, Accounting, Valuation, Financial Modeling, Video Tutorials

By continuing above step, you agree to our Terms of Use and Privacy Policy.

Free Investment Banking Course

IB Excel Templates, Accounting, Valuation, Financial Modeling, Video Tutorials

By continuing above step, you agree to our Terms of Use and Privacy Policy.
WallStreetMojo

Free Investment Banking Course

IB Excel Templates, Accounting, Valuation, Financial Modeling, Video Tutorials

By continuing above step, you agree to our Terms of Use and Privacy Policy.

* Please provide your correct email id. Login details for this Free course will be emailed to you

WallStreetMojo

Free Investment Banking Course

IB Excel Templates, Accounting, Valuation, Financial Modeling, Video Tutorials

By continuing above step, you agree to our Terms of Use and Privacy Policy.

* Please provide your correct email id. Login details for this Free course will be emailed to you

WallStreetMojo

Free Investment Banking Course

IB Excel Templates, Accounting, Valuation, Financial Modeling, Video Tutorials

By continuing above step, you agree to our Terms of Use and Privacy Policy.

* Please provide your correct email id. Login details for this Free course will be emailed to you

WallStreetMojo

Free Excel Course

Excel functions, Formula, Charts, Formatting creating excel dashboard & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.

* Please provide your correct email id. Login details for this Free course will be emailed to you

Limited Period Offer - VBA Training Course (6 courses, 35+ hours video) View More