我在用vb调用word生成表格时,遇到这样一个问题。但表格的行数在当前页放不下时,移到下页时发现下页的格式全乱啦(比如表格的行数有10行,在当前页有6行,其他的4行在下一页,结果到了下一页出来的效果是后面所有的文本都在表格中)效果如下图生成表格的代码如下:
 
Set oTable3 = WordApp.ActiveDocument.Tables.Add(Range:=.Range, NumRows:=k + 1, NumColumns:= _
                4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
                wdAutoFitFixed)
                
                   With WordApp.Selection.Tables(1)
        If .Style <> "网格型" Then
            .Style = "网格型"
        End If
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = True
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = True
    End With
      '  .MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
       ' .Cells.Merge
        
        '表格格式
            oTable3.Range.Font.Name = "宋体"
            oTable3.Range.Font.Size = 11
            oTable3.Range.Font.Bold = False
            oTable3.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
            oTable3.Rows(1).Cells(1).Range.Text = "第 i 条 "
            oTable3.Rows(1).Cells(2).Range.Text = "成绩A"
            oTable3.Rows(1).Cells(3).Range.Text = "成绩B"
            oTable3.Rows(1).Cells(4).Range.Text = "结果"
           
           For i = 1 To k
                oTable3.Rows(i + 1).Cells(1).Range.Text = "第" & i & "条"
                oTable3.Rows(i + 1).Cells(2).Range.Text = Result1(i)
                oTable3.Rows(i + 1).Cells(3).Range.Text = Result2(i)
                oTable3.Rows(i + 1).Cells(4).Range.Text = Result3(i)
           Next
          .MoveDown Unit:=wdLine, Count:=12
          .EndKey Unit:=wdStory
恳请大家帮我看看这段代码问题出在哪里?
程序运行时如果表格的行数不多,也就是说不超过当前页时,一切正常,如果超过就会出现如图所示的问题。