Reputation: 1239
I am creating a PowerPoint each week from some charts in Excel using VBA. However, the first slide needs to come from lasts week PowerPoint created.
The file path and name are both variables because they have the date in their title. I am able to account for this and have checked it with the actual file's name. It looks the same to me. However when I try to Open the file I get the ActiveX error/Run-time error 429. Any ideas would be much appreciated
Sub CreateNewPres()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim objPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim ppTextbox As PowerPoint.Shape
Set ppApp = New PowerPoint.Application
ppApp.Visible = True
ppApp.Activate
Set ppPres = ppApp.Presentations.Add
todayDate = Date
myTextDate = Format(todayDate, "yyyy-mm-dd")
myFilePath = "C:\Desktop\Main\" & myTextDate
myFileName = "\Meeting_" & myTextDate & ".pptx"
myFile = myFilePath & myFileName
objPres=_
Presentations.Open(myFile)
objPres.Slides(1).Copy
ppPres.Slides.Paste (ppPasteEnchancedMetafile)
Set ppTextbox = ppSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, _
Left:=0, Top:=0, Width:=30, Height:=10)
With myTextBox.TextFrame.TextRange.Text = todayDate
End With
Upvotes: 1
Views: 251
Reputation: 8868
Change this line:
objPres = Presentations.Open(myFile)
to this:
Set objPres = ppApp.Presentations.Open(myFile)
Upvotes: 1