Skip to content

Instantly share code, notes, and snippets.

@animegamer4422
Last active May 6, 2025 14:05
Show Gist options
  • Select an option

  • Save animegamer4422/243d5a96ffe372cc03d6fe9e4080b8ff to your computer and use it in GitHub Desktop.

Select an option

Save animegamer4422/243d5a96ffe372cc03d6fe9e4080b8ff to your computer and use it in GitHub Desktop.
PPT VBA Script
    ' Add a new slide (Title and Subtitle layout)
    Dim slide As Object
    Set slide = pres.Slides.Add(slideIndex, 1)
    
    ' Set title and subtitle
    slide.Shapes(1).TextFrame.TextRange.Text = title
    slide.Shapes(2).TextFrame.TextRange.Text = subtitle
End Sub

Sub CreatePresentation()
    Dim ppt As Object
    Dim pres As Object
    Dim slideIndex As Integer

    ' Create a new PowerPoint application and presentation
    Set ppt = CreateObject("PowerPoint.Application")
    Set pres = ppt.Presentations.Add
    ppt.Visible = True

    ' Initialize slideIndex
    slideIndex = 1

    ' Slide 1: Introduction
    CreateSlide pres, "Introduction", _
    "An overview of the topic and key points to be discussed in the presentation.", slideIndex
    slideIndex = slideIndex + 1

    ' Slide 2: Information
    CreateSlide pres, "Information", _
    "Detailed insights and data on the subject, providing context and analysis.", slideIndex
    slideIndex = slideIndex + 1

    ' Slide 3: Key Insights
    CreateSlide pres, "Key Insights", _
    "Summary of important findings, trends, and takeaways.", slideIndex
    slideIndex = slideIndex + 1

    ' Slide 4: Conclusion
    CreateSlide pres, "Conclusion", _
    "Final thoughts, implications, and potential future considerations.", slideIndex
    slideIndex = slideIndex + 1

    ' Slide 5: References
    CreateSlide pres, "References", _
    "Citations and sources used to support the information presented.", slideIndex
End Sub
@animegamer4422
Copy link
Author

Instructions to Use VBA Code in Excel for PowerPoint Presentation

Enabling Developer Mode in Excel

To use VBA in Excel, you need to enable the Developer tab. Follow these steps:

  1. Open Excel.
  2. Click on File > Options.
  3. In the Excel Options window, select Customize Ribbon.
  4. In the right pane, check the box for Developer.
  5. Click OK to save the settings.

The Developer tab should now appear in the Excel ribbon.

Using the VBA Code in Excel

Step 1: Open the VBA Editor

  1. Open Excel and press ALT + F11 to open the VBA Editor.
  2. In the VBA Editor, click Insert > Module to add a new module.

Step 2: Copy and Paste the Code

  1. Copy the VBA code from the provided script.
  2. Paste the copied code into the newly created module.

Step 3: Run the Code

  1. Close the VBA Editor and return to Excel.
  2. Open the Developer tab and click on Macros.
  3. Select CreatePresentation from the list.
  4. Click Run to execute the script.

Step 4: Viewing the PowerPoint Presentation

  • The script will open PowerPoint and create a presentation with slides based on the provided structure.
  • Ensure PowerPoint is installed on your system for the script to run successfully.

Now, you have a fully automated process to generate a PowerPoint presentation using Excel VBA!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment