View Single Post
 
Old 04-19-2022, 08:16 PM
soroush.kalantari soroush.kalantari is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Jun 2021
Posts: 124
soroush.kalantari is on a distinguished road
Default Need help in open a PowerPoint presentation form Excel and save it with different name

I have written a macro, in a part of it, I want to open a PowerPoint presentation form Excel workbook and save it with a different name, but when running the code, the code encounters an error in the last line (PPTX.ActivePresentation.saveas Filename:="C:\Users\s.kalantari\Desktop\dailyrepor t01.PPTX")
, saying “Run time error 424, object required. (The part of Macro with this issue is as following:

Sub Saveas()
Dim objPPTX As Object
Set objPPTX = createobject("PowerPoint.Application")
objPPTX.Visible = True
objPPTX.Presentations.Open "C:\Users\s.kalantari\Desktop\14010127.pptx", Untitled:=msoTrue
PPTX.ActivePresentation.saveas Filename:="C:\Users\s.kalantari\Desktop\dailyrepor t01.PPTX"

End Sub

Another question I have is this: If I want to use an Excel cell value (a variable) for the new name of saved file, dose the following code can do job? (Assuming the first problem is solved and cell value is not empty).

Sub Saveas()
Dim objPPTX As Object
Dim cell01 As variant
Cell01=Range("A1").Value
Set objPPTX = createobject("PowerPoint.Application")
objPPTX.Visible = True
objPPTX.Presentations.Open "C:\Users\s.kalantari\Desktop\14010127.pptx", Untitled:=msoTrue
PPTX.ActivePresentation.saveas Filename:="C:\Users\s.kalantari\Desktop\&cell01&”. PPTX"
End Sub
Any help will be appreciated. Thanks in advance.
Reply With Quote