各位大侠:
    我需要一份vb能控制word格式的程序原码,参考!
    或者是html,word,xls间相互转换的原码。                          谢谢!

解决方案 »

  1.   

    Private Sub mPrint2_Click()
    Dim strTemp2 As String
    strTemp2 = App.Path
    If Right$(strTemp2, 1) <> "\" Then strTemp2 = strTemp2 + "\"
    strTemp2 = strTemp2 & "print\动态表汇总.dot"
    Call myprint2(strTemp2)End SubPublic Sub myprint2(strtemp As String)
    Dim wapp As Word.Application
    Dim wdoc As Word.Document
    Dim mytable As Word.Table
    Dim myrange As Word.Range
    Dim i%, n%, j%
    'Dim myrow(200, 15)
    n = iTolClBh
    On Error Resume Next
    Set wapp = GetObject(, "word.application")
    If Err Then
        Err.Clear
        Set wapp = CreateObject("word.application")
    End If
    If Err Then
        MsgBox "不能运行 !"
    End If
    Screen.MousePointer = 11
    Set wdoc = wapp.Documents.Add(strtemp)
    Set mytable = wdoc.Tables(1)
    wdoc.Activate
    Set myrange = wdoc.Paragraphs(1).Range
    myrange.Collapse wdCollapseStart
    If n > 1 Then
        mytable.Cell(2, 1).Select
        Selection.InsertRows (n - 1)
    End If
    With mytable
    For i = 1 To n
        .Cell(i + 1, 1).Range.InsertAfter strClbhHJ(i) & "合计"
        .Cell(i + 1, 2).Range.InsertAfter Format$(sPreCashHJ(i), "0.00")
        .Cell(i + 1, 3).Range.InsertAfter Format$(sInCashHJ(i), "0.00")
        .Cell(i + 1, 4).Range.InsertAfter Format$(sTolOutCashHJ(i), "0.00")
        .Cell(i + 1, 5).Range.InsertAfter Format$(sLeftCashHJ(i), "0.00")
        For j = 1 To iZCKMnum
            .Cell(i + 1, 5 + j).Range.InsertAfter Format$(sZCKMcashHJ(j, i), "0.00")
        Next
    Next i
    End With
    wdoc.Application.Visible = True
    Screen.MousePointer = 1
    Set myrange = Nothing
    Set mytable = Nothing
    Set wdoc = Nothing
    Set wapp = NothingEnd Sub