View Single Post
 
Old 06-05-2017, 09:52 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Assuming the named folder exists and the bookmarks both exist and have content and there are no illegal filename characters in either bookmark (all of which should really be error trapped) then:

Code:
Private Sub CommandButton1_Click()
Const strPath As String = "C:\Users\sesa460426\Box Sync\My Projects\Quotes\"
Dim strName As String
    On Error Resume Next
    strName = ActiveDocument.Bookmarks("ClientName").Range.Text
    strName = strName & ActiveDocument.Bookmarks("QuoteNumber").Range.Text
    If Not strName = "" Then
        strName = strName & ".pdf"
        ActiveDocument.ExportAsFixedFormat OutputFileName:= _
                                           strPath & strName, _
                                           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
    End If
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote