piratemonkey22
New Member
- Joined
- Jul 23, 2019
- Messages
- 1
Hi,
I am having an issue whereby I wish to update a PPT template through Excel VBA on my Mac. I am able to open the template and save a copy of it no problem, however I am having a problem where I am unable to select objects on PPT slides to update without Excel crashing. Please see the below code which when executed gives the following error: 'Run-time error '429': ActiveX component can't create object'.
The code breaks at the highlighted line. In PPT I renamed the object to the name "TitleBox 1", which is what I am attempting to select. When I use the commented out line, Excel just completely crashes. Any advice on how to solve it would be very much appreciated or sources of information to look at to resolve this issue.
Sub Run_PPT()
Dim DestinationPPT As String
Dim Destination As String
Dim strName As String
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation
'Applies a variable to the PPT Template to be used throughout the Macro. Also opens the PPT file.
Set PowerPointApp = CreateObject("PowerPoint.Application")
DestinationPPT = "/Users/xxxx/xxxx/Template.pptx"
Set myPresentation = PowerPointApp.Presentations.Open(DestinationPPT)
'Title Slide
'myPresentation.Slides(1).Shapes("TitleBox 2").Select
ActivePresentation.Slides(1).Shapes("TitleBox 2").Select
'Saves the ppt as a pdf
Destination = "/Users/xxxx/xxxx/"
strName = "Test"
myPresentation.SaveAs FileName:=Destination & strName & ".PDF", FileFormat:=ppSaveAsPDF
MsgBox "Saved as :" & DestinationPPT & "" & strName & ".PDF"
End Sub
I am having an issue whereby I wish to update a PPT template through Excel VBA on my Mac. I am able to open the template and save a copy of it no problem, however I am having a problem where I am unable to select objects on PPT slides to update without Excel crashing. Please see the below code which when executed gives the following error: 'Run-time error '429': ActiveX component can't create object'.
The code breaks at the highlighted line. In PPT I renamed the object to the name "TitleBox 1", which is what I am attempting to select. When I use the commented out line, Excel just completely crashes. Any advice on how to solve it would be very much appreciated or sources of information to look at to resolve this issue.
Sub Run_PPT()
Dim DestinationPPT As String
Dim Destination As String
Dim strName As String
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation
'Applies a variable to the PPT Template to be used throughout the Macro. Also opens the PPT file.
Set PowerPointApp = CreateObject("PowerPoint.Application")
DestinationPPT = "/Users/xxxx/xxxx/Template.pptx"
Set myPresentation = PowerPointApp.Presentations.Open(DestinationPPT)
'Title Slide
'myPresentation.Slides(1).Shapes("TitleBox 2").Select
ActivePresentation.Slides(1).Shapes("TitleBox 2").Select
'Saves the ppt as a pdf
Destination = "/Users/xxxx/xxxx/"
strName = "Test"
myPresentation.SaveAs FileName:=Destination & strName & ".PDF", FileFormat:=ppSaveAsPDF
MsgBox "Saved as :" & DestinationPPT & "" & strName & ".PDF"
End Sub