Set oWord = CreateObject("Word.Application") '出错地方错误提示:部件要求挂起 由于其他应用程序忙,不能执行该操作,选择“切换到”按钮激活忙得应用程序并纠正该错误。
===================================为什么会这样,运行该程序的时候,我没有运行Word2000阿!!
===================================为什么会这样,运行该程序的时候,我没有运行Word2000阿!!
Dim wrdApp As Object
Dim f, fso As Object
Dim filepath As String
Dim Keywords As Stringfilepath = "c:\words"
Keywords = "abc"Set fso = CreateObject("Scripting.FileSystemObject")Set folders = fso.GetFolder(filepath)I = 0
For Each f In folders.Files
If LCase(Right(f.Name, Len(f.Name) - InStrRev(f.Name, "."))) = "doc" Then
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = False
wrdApp.Documents.Open FileName:=filepath & "\" & f.Name
If InStr(wrdApp.ActiveDocument.Content.Text, Keywords) <> 0 Then
MsgBox f.Name
End If
wrdApp.Quit
End If
Next
Set wrdApp = NothingEnd SubPrivate Sub Command2_Click()
Dim wrdApp As Object
Dim wrdRows, wrdCols, I As Long
Dim insText As StringwrdRows = 10: wrdCols = 10
insText = "TEST"Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = False
wrdApp.Documents.Open FileName:="C:\words\1.doc"
For I = 1 To wrdRows
wrdApp.ActiveDocument.Content.insertAfter vbCrLf
NextwrdApp.ActiveDocument.Content.GoTo What:=3, Which:=2, Count:=wrdRows
wrdApp.ActiveDocument.Content.insertAfter Space(wrdCols) & "PPPPPPPPPPPPP"wrdApp.ActiveDocument.Save
wrdApp.QuitSet wrdApp = NothingEnd Sub
但是如果希望重载word的事件处理,就必须withevents声明一个word.Application对象,但是实例化它的时候set oWord=new Word.Application就出错,错误信息跟hungryboy的一摸一样。本人正在发愁中,大家一起研究吧。
比如说我要在里加一个按钮后按一下能调用记事本程序这种要如何做呢