I have to post a lot of Excel charts to a specific PowerPoint document and I'm building out a macro in Excel VBA to do it for me.
I'm able to correctly open the PowerPoint presentation that I want to update, however I don't know how to set the presentation I just opened to a variable called MyPresentation
.
Dim myPresentation As PowerPoint.Presentation
Dim PowerPointApp As PowerPoint.Application
PowerPointApp.Presentations.Open Filename:="obscured filepath and name"`
Obviously there's some additional code, but I'm trying to set the Presentation I just opened in line 3 set to the MyPresentation
variable so I can reference the document I just opened.
I ended up finding a solution by the MVP Andy Pope.
Some relevant code snippets for future users. (FYI My PPT was already visible when I ran into the problem)
Dim DestinationPPT As String
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation
'Easier to define manually set links up front so it's easier to change/modify
DestinationPPT = "C:\yourfilepath\yourfilename.pptx"`
Lookup the Spreadsheet Guru's guide to opening PPT from Excel VBA
Then:
Set myPresentation = PowerPointApp.Presentations.Open(DestinationPPT)