View Single Post
 
Old 06-18-2019, 10:22 AM
smithan04 smithan04 is offline Windows 7 64bit Office 2010
Novice
 
Join Date: Jun 2019
Posts: 1
smithan04 is on a distinguished road
Default Macro to save as PDF with a new file name

I'm trying to create macro that will update and existing Word document which has embedded Excel objects into a PDF with a date stamp at the end of its name. The macro works good until today when I opened the PDF I receive an error that reads "Adobe Reader could not open 'Weekly Report_0618.pdf' because it is either not a supported file type or because the file has been damaged..." Please let me know what I'm doing wrong.

Sub OpenWordDoc()


Dim filename, filepath
Dim objWord
Dim objDoc


Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Open("H:\Weekly\Weekly Report.docx")



objWord.Visible = True

objDoc.Fields.Update





Application.DisplayAlerts = False


filepath = "Z:\00_Weekly Forecast\"
filename = "Weekly Report_" & InputBox("Enter Forecast Date") & ".pdf"
objDoc.SaveAs filepath & filename


Application.DisplayAlerts = True



objDoc.Close


End Sub
Reply With Quote