View Single Post
 
Old 06-05-2014, 04:20 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,488
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Try something along the lines of:
Code:
Dim DocCount As Long, MaxDocs As Integer, DocName As String
With ActiveDocument
  .Repaginate
  MaxDocs = .Sections.Count
  For DocCount = 1 To MaxDocs
    With .Sections(DocCount).Footers(wdHeaderFooterPrimary).Range
      DocName = Trim(Left(Replace(.Text, vbCr, " "), Len(Replace(.Text, vbCr, " ")) - 47)) & ".pdf"
    End With
    .ExportAsFixedFormat OutputFileName:=.Path & "\" & DocName, ExportFormat:=wdExportFormatPDF, _
      OpenAfterExport:=False, Range:=wdExportFromTo, From:=DocCount * 2 - 1, To:=DocCount * 2, _
      OptimizeFor:=wdExportOptimizeForPrint, Item:=wdExportDocumentContent, IncludeDocProps:=True, _
      CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:=True, _
      KeepIRM:=True, UseISO19005_1:=False
  Next DocCount
End With
Note: It's possible your errors are due to the footer text length not being more than the 47 characters you're trying to reduce it by. With the code you had, it was also possible you were including one or more paragraph breaks in the prospective filename.

PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote