none
VB.NET 如何合并单元格? RRS feed

  • 问题

  • 大家好,利用VB.NET向word中输入一个6行两列的表格。其中最后两列想合并单元格,目前的代码是这样的:

        Public Sub InsertTable()


            Dim r As Integer, c As Integer
            otable = oDocument.Tables.Add(oDocument.Bookmarks.Item("\endofdoc").Range, 2, 6)
            otable.Range.ParagraphFormat.SpaceAfter = 6
            For r = 1 To 2
                For c = 1 To 6
                    If r = 1 And c = 1 Then
                        otable.Cell(r, c).Range.Text = "试题"
                    End If
                    If r = 1 And c = 2 Then
                        otable.Cell(r, c).Range.Text = "一"
                    End If
                    If r = 1 And c = 3 Then
                        otable.Cell(r, c).Range.Text = "二"
                    End If
                    If r = 1 And c = 4 Then
                        otable.Cell(r, c).Range.Text = "三"
                    End If
                    If r = 2 And c = 1 Then
                        otable.Cell(r, c).Range.Text = "得分"
                    End If

                Next
            Next
            otable.Rows.Item(1).Range.Font.Bold = True
            otable.Rows.Item(1).Range.Font.Italic = True

        End Sub

    实现效果如图:


    想问下高手两个红框如何合并两列单元格呢?感谢


    煜诚海参专卖 淘宝店铺:http://jinweb.taobao.com

    2013年9月28日 2:20

答案