Save as PDF in specific location with filename using todays date
Hello,
I'm pretty new to VBA and trying to work out how to achieve the following:
I have a one page word document which I need to update on a weekly basis once a week (say for example every Tuesday). I want to save this as a PDF to a particular file location on my companies network, which is a mapped drive (For example, W:\Tenants\Rent\).
I would like the file name to be just the date in YYYY-MM-DD format. (for example, 2017-08-15.pdf).
I would like to be prompted if the file already exists to check if it is okay to overwrite the existing file.
I've found a host of similar related questions, but not any that match my requirements, or that I can get to work.
Any help with some code would be more than appreciated!
I've found various code, such as the following, which save the Word document as a PDF, but it only saves in the folder that the original Word document is in, and the filename is not changed as I would like it to.
Sub Print_to_PDF()
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
Replace(ActiveDocument.FullName, ".docx", ".pdf"), _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, Item:= _
wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub
Mark
|