![]() |
|
#2
|
||||
|
||||
|
If you just want to save with the data as the filename then that is easy enough. The following will warn if the folder is missing of the file exists.
Code:
Sub Print_to_PDF()
Dim strName As String
Dim fso As Object
Const strPath As String = "W:\Tenants\Rent\"
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(strPath) Then
MsgBox "The folder " & strPath & " does not exist."
GoTo lbl_Exit
End If
strName = strPath & Format(Date, "yyyy-mm-dd") & ".pdf"
If fso.FileExists(strName) Then
If MsgBox("File " & strName & " exists." & vbCr & vbCr & _
"Do you want to overwrite", vbYesNo) = vbNo Then
GoTo lbl_Exit
End If
End If
ActiveDocument.ExportAsFixedFormat OutputFileName:=strName, _
ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=True, _
OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, _
Item:=wdExportDocumentContent, _
IncludeDocProps:=False, _
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, _
DocStructureTags:=True, _
BitmapMissingFonts:=True, _
UseISO19005_1:=False
lbl_Exit:
Set fso = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with Macro to Save Word File as PDF in Specific Location | ekimisme | Word VBA | 1 | 06-07-2017 10:40 PM |
Save to PDF with predetermined filename and specific folder path
|
cutemich | Word VBA | 1 | 05-09-2017 06:27 PM |
Save document multiple times with date as filename
|
JonniBravo | Word | 6 | 03-13-2017 11:35 AM |
Macro: How to get this macro to save to a specific location
|
LOUF | Word VBA | 1 | 12-07-2015 06:47 PM |
| Highlight row based on todays date problem | manxman79 | Excel | 6 | 11-17-2014 09:06 AM |