title: Word 2003 vs. 2007/2010 Automation
body: <p>I'm automating Word in a VB6 application and I'm getting an exception when the host machine is using Word 2007 or 2010 but not on a machine running Word 2003.  The exception is </p>
  
  <blockquote>
    <p>Runtime error '4605': "This method or property is not available because the object refers >to the end of a table row."</p>
  </blockquote>
  
  <p>The exception is thrown on the seventh iteration of the following loop, on the line which attempts to insert a page break:</p>
  
  <pre><code>For num = 1 To breakArrCount
      Set myRange = oworddoc.Paragraphs(breakArr(num)).Range
      With myRange
          On Error Resume Next
          .Collapse Direction:=wdCollapseEnd
          .InsertBreak Type:=wdPageBreak
      End With
  Next
  </code></pre>
  
  <p>The array, breakArr, stores the indexes of the paragraphs in the document which are to be followed by a page break.</p>
  
  <p>Interestingly enough, if I break out of the loop prior to the exception (i.e. after the 6th iteration) and view the generated document, I notice that the page breaks (for the first 6 pages) are inserted in different points in Word 2007/2010 than in 2003.</p>
  
  <p>Why would there be a difference?  Does anybody know what I should be doing differently?</p>
  
  <p>Thanks.</p>