title: Word macro to split document is creating an extra page
body: <p>I created a macro which, based on user input, splits the Word document into smaller documents and then outputs them as a .pdf with a unique name. Each individual document though is outputting with an extra blank page on the back, which at no point is in the original document. Is there any way to stop this happening/remove the back page before saving to .pdf? I tried removing the final page by section break but that also didn't work.</p>
  <pre><code>Sub SplitToPDF()
  
      Dim docMultiple As Document
      Dim docSingle As Document
      Dim rngPage As Range
      Dim iCurrentPage As Integer
      Dim iPageCount As Integer
      Dim strNewFileName As String
      Dim fDialog As FileDialog
      Dim x As Integer
      Dim Response As VbMsgBoxResult
      Dim userInput As Integer
      Dim fso
      Dim currentDate As String
      Dim customerName As String
      Dim currentMonth As String
      Dim currentYear As Integer
          
      Response = MsgBox(&quot;Insturctions for use:&quot; &amp; vbNewLine &amp; &quot;Please ensure the first blank page has been deleted.&quot; &amp; vbNewLine &amp; &quot;Please ensure you have saved (and re-named) this document to the fund operation name.&quot; &amp; vbNewLine &amp; vbNewLine &amp; &quot;This will also overwrite any other split you have done in the same folder. Continue?&quot;, vbExclamation + vbYesNo, &quot;Warning!&quot;)
      If Response = vbNo Then Exit Sub
      
      inputData = InputBox(&quot;Please enter the length of each letter below.&quot;, &quot;Notice length:&quot;)
      If inputData = &quot;&quot; Then Exit Sub
      
      '   1 Create dialog for saving and get directory details
      Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
      With fDialog
          .Title = &quot;Select folder to save split files&quot;
          .AllowMultiSelect = False
          .InitialView = msoFileDialogViewList
          If .Show &lt;&gt; -1 Then
              MsgBox &quot;Cancelled By User&quot;, vbInformation
              Exit Sub
          End If
          DocDir = fDialog.SelectedItems.Item(1)
      End With
      
      Application.ScreenUpdating = False
      
      Set docMultiple = ActiveDocument
      Set rngPage = docMultiple.Range
      iCurrentPage = 1
      iPageCount = docMultiple.BuiltInDocumentProperties(wdPropertyPages)
      
      '   2 Loop through each page set and copy/paste data
      Do Until iCurrentPage &gt; iPageCount
          If iCurrentPage = iPageCount Then
              rngPage.End = ActiveDocument.Range.End
          Else
              Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage + inputData
              rngPage.End = Selection.Start
          End If
          
          rngPage.Copy
          Set docSingle = Documents.Add
          docSingle.Range.Paste
          
          For i = 0 To docSingle.Sections.Count
          Next
      
          Set delSec = docSingle.Sections(i)
          delSec.Range.Delete
          
      '   3 Variable for document name
          Application.Selection.Find.Execute &quot;customer: &quot;
          Application.Selection.Expand wdLine
          customerName = Replace(Application.Selection.Text, &quot;customer: &quot;, &quot;&quot;)
          x = Len(customerName) - 1
          customerName = Left(customerName, x)
          
          Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
          
          currentDate = Replace(Date, &quot;/&quot;, &quot;-&quot;)
          currentMonth = Format(currentDate, &quot;MMM&quot;)
          currentYear = Format(currentDate, &quot;YY&quot;)
          currentDate = currentMonth &amp; &quot;_&quot; &amp; currentYear
          
          strNewFileName = fso.GetBaseName(docMultiple) &amp; &quot;_&quot; &amp; currentDate &amp; &quot;_&quot; &amp; customerName &amp; &quot;.pdf&quot;
          docSingle.SaveAs FileName:=DocDir &amp; &quot;\&quot; &amp; strNewFileName, FileFormat:=wdFormatPDF
          
          iCurrentPage = iCurrentPage + inputData
          
          docSingle.Close SaveChanges:=wdDoNotSaveChanges
          rngPage.Collapse wdCollapseEnd
      Loop
      
      Application.ScreenUpdating = True
      
      MsgBox &quot;Complete&quot;, vbInformation
      
      Set docMultiple = Nothing
      Set docSingle = Nothing
      Set rngPage = Nothing
  End Sub
  </code></pre>