我用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环境中调试这段程序是不会报错的。请帮忙解答一下,非常感谢!
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环境中调试这段程序是不会报错的。请帮忙解答一下,非常感谢!
在2000下重新引用excel对象,ku记是office版本问题