Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-22-2013, 11:29 AM
amlong amlong is offline Save as PDF - How to add extra functionality to split by page break Windows XP Save as PDF - How to add extra functionality to split by page break Office 2007
Novice
Save as PDF - How to add extra functionality to split by page break
 
Join Date: Feb 2013
Posts: 5
amlong is on a distinguished road
Default Save as PDF - How to add extra functionality to split by page break

The code you posted at https://www.msofficeforums.com/word-...html#post18401 works perfectly, but can it be enhanced to split the word mail merge by page break and save each individual file to pdf?



Any assistance you could give would be appreciated.

Thanks
A
Code:
Sub SaveToPDF()
Dim StrPath As String, StrName As String, Result
With ActiveDocument
  On Error GoTo Errhandler
  StrPath = GetFolder & "\"
  StrName = Split(.Name, ".")(0)
  While Dir(StrPath & StrName & ".pdf") <> ""
    Result = InputBox("WARNING - A file already exists with the name:" & vbCr & _
      Split(.Name, ".")(0) & vbCr & _
      "You may edit the filename or continue without editing." _
      & vbCr & vbTab & vbTab & vbTab & "Proceed?", "File Exists", StrName)
    If Result = vbCancel Then Exit Sub
    If StrName = Result Then GoTo Overwrite
    StrName = Result
  Wend
Overwrite:
  .ExportAsFixedFormat OutputFileName:=StrPath & StrName & ".pdf", _
  ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, _
  OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
  Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
  CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
  BitmapMissingFonts:=True, UseISO19005_1:=False
End With
Errhandler:
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function

Last edited by macropod; 02-22-2013 at 08:41 PM. Reason: Split to new thread, with links & code
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Save as PDF - How to add extra functionality to split by page break Delete a page after Section Break Next Page Aston Word 9 04-27-2022 07:38 AM
Page break? Jon Word 3 01-29-2013 09:08 AM
Save as PDF - How to add extra functionality to split by page break Word extra spacing on page break ellinj Word 4 03-21-2011 05:12 PM
paragaph hard break, soft break and ...strange break czomberzdaniela Word 2 12-03-2010 06:58 PM
Page Break Manolo Word 0 04-29-2009 11:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft