View Single Post
 
Old 06-05-2017, 09:18 AM
pamtupac pamtupac is offline Windows 10 Office 2016
Novice
 
Join Date: Jun 2017
Posts: 2
pamtupac is on a distinguished road
Default macro to save as pdf with name from bookmark

hi all,

i'm trying to create a command button in word and attach a macro that automatically saves the doc as a pdf to a specified folder with file with the name coming from 2 bookmark references with a space and dash in between name.

here is what i have so far:

Private Sub CommandButton1_Click()

ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"C:\Users\sesa460426\Box Sync\My Projects\Quotes" & ClientName = .Bookmarks("ClientName").Range.Text&.Bookmarks("Qu oteNumber").Range.Text & (".pdf"), _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
ChangeFileOpenDirectory "C:\Users\sesa460426\Box Sync\My Projects\Quotes"
End Sub


i keep getting an invalid or unqualified reference error and it highlights the .bookmarks part. i'm very very new to vba so if someone can please help me.

ps. i've also tried adding activedocument before the .bookmarks part but then i get a different error.

thanks in advance
Reply With Quote