title: Split Word document into multiple parts and keep the text format
body: <p><strong>My Task</strong></p>
  
  <p>Split a Word document into multiple parts based on a delimiter while preserving the text format.</p>
  
  <p><strong>Where I am?</strong></p>
  
  <p>I tried a basic example with one document but without an array and it worked. </p>
  
  <pre><code>Option Explicit
  
  Public Sub CopyWithFormat()
      Dim docDestination As Word.Document
      Dim docSource      As Word.Document
  
      Set docDestination = ActiveDocument
      Set docSource      = Documents.Add
  
      docSource.Range.FormattedText = docDestination.Range.FormattedText
      docSource.SaveAs "C:\Temp\" &amp; "test.docx"
      docSource.Close True             
  End Sub
  </code></pre>
  
  <p><strong>Where do I stuck?</strong></p>
  
  <p>I put the whole document into an array and loop through it. Right not I get an <code>error 424 - Object necessary</code> on this line:
  <code>docDestination.Range.FormattedText = arrNotes(I)</code>.</p>
  
  <p>I also tried these four variants without luck:</p>
  
  <pre><code>docDestination.Range.FormattedText = arrNotes(I).Range.FormattedText
  docDestination.Range.FormattedText = arrNotes(I).FormattedText
  docDestination.Range.FormattedText = arrNotes.Range.FormattedText(I)
  docDestination.Range.FormattedText = arrNotes.FormattedText(I)
  </code></pre>
  
  <p>Could you please help and point me into the right direction on how to access the array properly?</p>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>Option Explicit
  
  Sub SplitDocument(delim As String, strFilename As String)
      Dim docSource      As Word.Document
      Dim docDestination As Word.Document
      Dim I              As Long
      Dim X              As Long
      Dim Response       As Integer
      Dim arrNotes
  
      Set docSource = ActiveDocument
      arrNotes      = Split(docSource.Range, delim)
  
      For I = LBound(arrNotes) To UBound(arrNotes)
          If Trim(arrNotes(I)) &lt;&gt; "" Then
              X = X + 1
              Set docDestination = Documents.Add
              docDestination.Range.FormattedText = arrNotes(I) 'throws error 424
              docDestination.SaveAs ThisDocument.Path &amp; "\" &amp; strFilename &amp; Format(X, "0000")
              docDestination.Close True
          End If
      Next I
  End Sub
  
  Sub test()
      'delimiter &amp; filename
      SplitDocument "###", "Articles "
  End Sub
  </code></pre>