none
vb开发 文件转换器中遇到问题,求助 RRS feed

  • 问题

  •  

    Sub 表格处理()
        On Error Resume Next
        Dim q, i As Single, bh(500) As String
        Dim c(20) As Single, d(500, 100) As Single
        For Each T In ActiveDocument.Tables
            q = T.Rows.Count
            For i = 1 To q
                转换中.Label3.Caption = "表格初始化"
                转换中.Label4.Caption = Int(i * 100 / q + 0.5) & "%"
                c(i) = T.Rows(i).Cells.Count
            Next i
            i = 1
            J = 1
            a = 1
            For Each oCell In T.Range.Cells
                d(i, J) = Int(42 * oCell.Width / 450.25 + 0.5)
                i = i + 1
                J = J + 1
                g = i - 1
            Next
            For m = 1 To q
                bh(m) = ""
                k = 1
                For n = a To g
                    If k <= c(m) Then
                        d(m, k) = d(n, n)
                        bh(m) = bh(m) & ",K" & d(m, k)
                    End If
                    k = k + 1
                Next n
                a = a + c(m)
                bh(m) = bh(m) & "F〗"
                k = 0
            Next m
            For Each oCell In T.Range.Cells
                With oCell
                    If q > 1 And c(q) > 1 Then
                        If .ColumnIndex = 1 And .RowIndex = 1 Then
                            hk = Int(.Height / 12 + 0.5)
                            If hk <= 1 Or hk > 1000 Then
                                hk = 2
                            End If
                            bh(1) = "〖BHDFG" & hk & bh(1)
                            .Range.InsertBefore("〖BG(!〗" & bh(1))
                        Else
                            If .ColumnIndex = c(q) And .RowIndex = q Then
                                .Range.InsertAfter("〖BG)F〗")
                                .Range.InsertBefore("〖〗")
                            Else
                                If .ColumnIndex > 1 Then
                                    .Range.InsertBefore("〖〗")
                                End If
                            End If
                        End If
                        For m = 2 To q
                            转换中.Label3.Caption = "表格处理"
                            转换中.Label4.Caption = Int(m * 100 / q + 0.5) & "%"
                            If .ColumnIndex = 1 And .RowIndex = m Then
                                hk = Int(.Height / 12 + 0.5)
                                If hk <= 1 Or hk > 1000 Then
                                    hk = 2
                                End If
                                bh(m) = "〖BHDFG" & hk & bh(m)
                                .Range.InsertBefore(bh(m))
                            End If
                        Next

                    Else
                        If q = 1 And c(q) = 1 Then
                            .Range.InsertBefore("〖BG(!〗〖BHDFG2,FK" & d(1, 1) & "F〗")
                            .Range.InsertAfter("〖BG)F〗")
                        End If
                        If q = 2 And c(q) = 1 Then
                            If .ColumnIndex = 1 And .RowIndex = 1 Then
                                .Range.InsertBefore("〖BG(!〗〖BHDFG2,FK" & d(1, 1) & "F〗")
                            Else
                                If .ColumnIndex = 1 And .RowIndex = 2 Then
                                    .Range.InsertAfter("〖BG)F〗")
                                    .Range.InsertBefore(bh(2))
                                Else
                                    .Range.InsertBefore("〖〗")
                                End If
                            End If
                        End If
                        If q = 1 And c(q) = 2 Then
                            If .ColumnIndex = 1 And .RowIndex = 1 Then
                                .Range.InsertBefore("〖BG(!〗" & bh(1))
                            Else
                                .Range.InsertAfter("〖BG)F〗")
                                .Range.InsertBefore("〖〗")
                            End If
                        End If
                    End If
                End With
            Next oCell
            T.ConvertToText(Separator:=wdSeparateByTabs, NestedTables:=True)
        Next
    End Sub

    此段是word转成北大方正语言的表格处理部分,没有子表处理功能(拆分过后的表格)如何读出子表的数据,并插在相应的地方.

    请高手回复一下,有没有关于rtf的技术文档,如果用vb.net写程序,转rtf格式,最好提供一下源码.谢谢

     

    2008年2月5日 12:15