title: MS Word Save each page as separate PDF document named with specific text within the document
body: <p>I want to convert a Microsoft excel table of invoice data and populating a mail merge template and once it is merged, I need to split up each invoice and save it as a pdf.</p>
  
  <p>The code below does what I want but saves them as 1,2,3 etc.  The name I would like to be used is the invoice number found on the document (the first 8 characters of each page excluding header).</p>
  
  <p>This is what my code looks like now:</p>
  
  <pre><code> Sub BreakOnPage()
       Selection.HomeKey Unit:=wdStory
       ' Used to set criteria for moving through the document by page.
       Application.Browser.Target = wdBrowsePage
  
       For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")
  
       'Select and copy the text to the clipboard.
       ActiveDocument.Bookmarks("\page").Range.Copy
  
       ' Open new document to paste the content of the clipboard into.
       Documents.Add
       Selection.Paste
       ' Removes the break that is copied at the end of the page, if any.
       Selection.TypeBackspace
       Selection.HomeKey Unit:=wdStory
       Selection.EndKey Unit:=wdStory
       Selection.TypeBackspace
       Selection.Delete Unit:=wdWord, Count:=1
       Selection.Delete Unit:=wdCharacter, Count:=1
  
       Dim strInvoiceNumber As String
       Selection.HomeKey Unit:=wdStory
       With Selection.Find
       .ClearFormatting
       Text:="^#^#^#^#^#^#^#^#"
       .Forward = True
       .MatchWildcards = False
       .Execute
       End With
  
       ' Defines the DocNum
  
       strInvoiceNumber = Selection.Text
  
  
       ' Exports the document to a pdf file and saves in sequence starting at 1 and closes the word document without saving
  
       ActiveDocument.ExportAsFixedFormat OutputFileName:= _
       "C:\Users\MLock\Documents\MacrosDocs\" &amp; strInvoiceNumber &amp; ".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
  
  
       ActiveDocument.Close savechanges:=wdDoNotSaveChanges
  
       ' Move the selection to the next page in the document.
       Application.Browser.Next
       Next i
       ' ActiveDocument.Close savechanges:=wdDoNotSaveChanges
   End Sub
  </code></pre>
  
  <p>How do I set the name of the PDF document here?</p>