代码:
Private Sub CmdPrint_Click()
    Dim str As String
    Dim newDoc As Object
    Dim i, n As Integer
    
    On Error GoTo errOut
    frmWait.Show
    str = App.Path + "\评标专家组\"
    ' 调用Word
    Set newDoc = CreateObject("Word.Application")
    
    Dim rngFormat As Range
    newDoc.Documents.Add 'Open FileName:=str, Visible:=True
    Set rngFormat = ActiveDocument.Range(Start:=0, End:=0)
    
        
    With rngFormat
        .InsertAfter Text:=project + "评标专家组成员:"
        .InsertParagraphAfter
        .InsertParagraphAfter
        With .Font
            .Name = "宋体"
            .Size = 18
            .Bold = True
        End With
    End With
    
    Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(1).Range.End, End:=newDoc.Documents(1).Range.End)
    With rngFormat
        .InsertAfter Text:="1、管理人员:"
        .InsertParagraphAfter
        With .Font
            .Name = "宋体"
            .Size = 16
        End With
    End With
    
    n = ListXM.ListCount
    
    Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(3).Range.End, End:=newDoc.Documents(1).Range.End)
    With rngFormat
        For i = 0 To n - 1
            If i = 0 Then .InsertAfter Text:=Space(8)
            .InsertAfter Text:=ListXM.List(i)
            .InsertAfter Text:=Space(4)
            With .Font
                .Name = "宋体"
                .Size = 14
            End With
        Next
        .InsertParagraphAfter
    End With
    
    Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(4).Range.End, End:=newDoc.Documents(1).Range.End)
    With rngFormat
        .InsertAfter Text:="2、技术人员:"
        .InsertParagraphAfter
        With .Font
            .Name = "宋体"
            .Size = 16
        End With
    End With
    
    n = ListJS.ListCount
    
    Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(5).Range.End, End:=newDoc.Documents(1).Range.End)
    With rngFormat
        For i = 0 To n - 1
            If i = 0 Then .InsertAfter Text:=Space(8)
            .InsertAfter Text:=ListJS.List(i)
            .InsertAfter Text:=Space(4)
            With .Font
                .Name = "宋体"
                .Size = 14
            End With
        Next
        .InsertParagraphAfter
        .InsertParagraphAfter
        .InsertParagraphAfter
    End With
    
    Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(8).Range.End, End:=newDoc.Documents(1).Range.End)
    With rngFormat
        .InsertAfter Text:=Space(50)
        .InsertAfter Text:=Date + Time
        With .Font
            .Name = "宋体"
            .Size = 12
        End With
    End With
    
    ActiveDocument.SaveAs FileName:=str + project + "评标专家组成员"
    ActiveDocument.PrintOut Range:=wdPrintCurrentPage
    ' 关闭文件,关闭Word
    newDoc.Documents(1).Close
    newDoc.Quit
    Set rngFormat = Nothing
    Set newDoc = Nothing
    Exit Sub
errOut:
    Unload frmWait
    MsgBox Err.Description, vbCritical, "错误"
End Sub在本机上调试通过,并用wise installation system 9.02打包在装有Win98的机子上安装后,运行出现“自动化错误”,两台机子都装的是Office XP,但是在其他装有Win2000的机子上就可以运行,我的系统是WinXP home版。请教!

解决方案 »

  1.   

    谢谢,麻烦找到了贴出来或[email protected]
      

  2.   

    你是在win2000下作的?  你试试在win98下重新编译,然后再打包,看看能不能分发到其它的win98上
      

  3.   

    在本机上调试通过,并用wise installation system 9.02打包在装有Win98的机子上安装后,运行出现“自动化错误”,两台机子都装的是Office XP,但是在其他装有Win2000的机子上就可以运行,我的系统是WinXP home版。用wise installation system 9.02沒有將For Win98的Office Xp的運行庫打包
    解決:在Win98下安裝一個Office Xp或Word Xp
      

  4.   

    Set newDoc = CreateObject("Word.Application.9") '.9 为Word2000
                                                    '.10 为WordXP
      

  5.   

    VB+word的打印“自动化错误”问题,100分答谢(很想给200分,可MSDN不让啊…)!MSDN竟然不让你给分?我的MSDN就从来不管我。:)
      

  6.   

    两台机子上都装的是Office XP,包括Win98和我的WinXP-home。
    是啊,我填的是200分,结果被警告说最多只能给100分……