Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-18-2019, 10:22 AM
smithan04 smithan04 is offline Macro to save as PDF with a new file name Windows 7 64bit Macro to save as PDF with a new file name Office 2010
Novice
Macro to save as PDF with a new file name
 
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
  #2  
Old 06-18-2019, 03:46 PM
macropod's Avatar
macropod macropod is online now Macro to save as PDF with a new file name Windows 7 64bit Macro to save as PDF with a new file name Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Use:
objDoc.SaveAs filepath & filename, 17 '17 = wdFormatPDF
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

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
Macro to save as PDF with a new file name Save As PDF Macro/VBA with Predetermined File Name DefinedDesign Word VBA 9 10-29-2014 01:48 PM
Macro to save as PDF with a new file name Choose file name Save As macro gbaker Excel Programming 28 07-22-2014 03:54 PM
Macro to save as PDF with a new file name Save As Macro that changes the file name also rosscortb Word VBA 5 05-19-2014 08:40 AM
Macro to save as PDF with a new file name Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft