I created a form in word with legacy tools only. I created a save as command but
ID: 3560686 • Letter: I
Question
I created a form in word with legacy tools only.
I created a save as command button which works but it saves under a predetermined name: "safety tour".
I was wondering if it is possible to save as by defining the name of the file on the content that would be filled in by users adding the ref number and the date to the name, & & . Is it possible to ask to find the content by bookmarking the fields?
the code I have so far is:
Private Sub CBSave_PDF_Click()
' SavePDF Macro
'
'
ChangeFileOpenDirectory "C:Temp"
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"C:TempSafety Tour.pdf", ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=True, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
True, UseISO19005_1:=False
End Sub
Thanks for your help
Explanation / Answer
#%@%Assign a bookmark to the FormField that contains the Reference and then use
Dim strFileName as String(*&
With ActiveDocument
strFileName = .FormFields("BookmarkNameoftheReferenceFormField").Result & Format(Date, "yyyyMMdd") & ".pdf"
.ExportAsFixedFormat OutputFileName:= _
"C:Temp" & strFileName, ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=True, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
True, UseISO19005_1:=False
End With
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.