|
这个代码之前一直都可以用,但是突然有了这个提示,重装了office也是打不开 怎么回事!求助各位大神
代码如下:之前都一直没问题,突然不能用了,WORD打不开
Sub 查询()
Application.ScreenUpdating = False
Dim i, arr, Word As Object
Set Word = CreateObject("Word.Application")
Word.Visible = 1
arr = UsedRange
Set MyWord = Word.Documents.Open(ThisWorkbook.Path & "\" & "教材原始文件.doc")
On Error Resume Next
For i = 2 To UBound(arr)
If arr(i, 1) <> "" And arr(i, 3) <> 1 Then
Word.Selection.Find.ClearFormatting '开启搜索模式
With Word.Selection.Find
Do While .Execute(FindText:=arr(i, 1)) = True
tim = tim + 1
Loop
End With
'MsgBox ("当前文档共查找到" + Str(tim) + "个" + Text), 48, "搜索结果提示"
'arr(i, 3).FormulaR1C1 = "d" '进行备注
'Range("C2").FormulaR1C1 = Str(tim)
'ActiveCell.FormulaR1C1 = Str(tim)
'Range("A3").Value = "w"
Cells(i, 3).Value = Str(tim)
tim = 0
Word.Selection.WholeStory '全选对象,重头查找
End If
Next
Word.Documents.Close True
Word.Application.Quit
'[a1].CurrentRegion = arr '标识
Set MyWord = Nothing
MsgBox "查询完毕!", 48, "温馨提示!"
End Sub
|
|