#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
Use:
objDoc.SaveAs filepath & filename, 17 '17 = wdFormatPDF
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Save an excel file with a macro ? | nospamdav999 | Excel | 0 | 05-09-2017 01:11 PM |
Save As PDF Macro/VBA with Predetermined File Name | DefinedDesign | Word VBA | 9 | 10-29-2014 01:48 PM |
Choose file name Save As macro | gbaker | Excel Programming | 28 | 07-22-2014 03:54 PM |
Save As Macro that changes the file name also | rosscortb | Word VBA | 5 | 05-19-2014 08:40 AM |
Word Macro: Save file as text with current file name | jabberwocky12 | Word VBA | 2 | 10-22-2010 12:23 PM |