我用vb写了两个操作word文档的dll都是如此,在nt的机器上没有问题,可是移到win2000机器下就报错:Automation error
The message filter indicated that the application is busy. 我的程序如下:
    Set WordApp = CreateObject("Word.Application")
    Set WordDoc = WordApp.Documents.Open(tmpPath)
    
    WordApp.Visible = False
    
    WordApp.ActiveDocument.Books("title").Select
    WordApp.Selection.TypeText title
    
    WordApp.ActiveDocument.Books("case").Select
    WordApp.Selection.TypeText casestr
    
    For i = LBound(canid) To UBound(canid)
    'For i = 0 To 1
        If i = 0 Then
            'company
            WordApp.ActiveDocument.Books("firstLbl").Select
            WordApp.Selection.TypeText Text:=company(i)
            'name
            WordApp.Selection.MoveRight 'Unit:=wdCharacter, Count:=1
            WordApp.Selection.TypeText Text:=name(i)
            'position
            WordApp.Selection.MoveRight 'Unit:=wdCharacter, Count:=1
            WordApp.Selection.TypeText Text:=position(i)
            'comment
            WordApp.Selection.MoveRight 'Unit:=wdCharacter, Count:=1
            WordApp.Selection.TypeText Text:=comment(i)
       Else
            '新增一行
            WordApp.Selection.MoveRight 'Unit:=wdCharacter, Count:=1
            WordApp.Selection.InsertRows 1
            WordApp.Selection.Collapse 'Direction:=wdCollapseStart
            'company
            WordApp.Selection.MoveRight 'Unit:=wdCharacter, Count:=1
            WordApp.Selection.TypeText Text:=company(i)
            'name
            WordApp.Selection.MoveRight 'Unit:=wdCharacter, Count:=1
            WordApp.Selection.TypeText Text:=name(i)
            'position
            WordApp.Selection.MoveRight 'Unit:=wdCharacter, Count:=1
            WordApp.Selection.TypeText Text:=position(i)
            'comment
            WordApp.Selection.MoveRight 'Unit:=wdCharacter, Count:=1
            WordApp.Selection.TypeText Text:=comment(i)
        End If
    Next
    
    If (Not WordDoc Is Nothing) Then
        Set WordDoc = Nothing
    End If
    If (Not WordApp Is Nothing) Then
        WordApp.Quit
        Set WordApp = Nothing
    End If有一点特别奇怪,我在win2000的机器上在vb环境中调试这段程序是不会报错的。请帮忙解答一下,非常感谢!

解决方案 »

  1.   

    不懂,帮你顶,我猜是office版本的问题现在还有用NT的呢?太牛了!
      

  2.   

    就是nt太旧了,所以要换win2000了,才发现这个问题,可是又不知道问题出在哪里。我用的是word2000,nt和win2000的机器都是用的word2000,要么把你们的程序贴给我看看呢。
      

  3.   

    代码应该没问题
    在2000下重新引用excel对象,ku记是office版本问题
      

  4.   

    也许不是什么版本或NT的问题,我也遇到过类似问题,主要是对DLL的引用产生的,开发、安装等过程不知为何对DLL的引用发生变化,改起来很麻烦,后来就不用DLL,改用类模块就没这些问题。