|
![](https://clubstatic.excelhome.net/image/common/ico_lz.png)
楼主 |
发表于 2019-10-23 14:28
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 查找定位()
Dim WordApp, wordD
Dim cPath$, cFile$, i%, h, l, str1
cPath = ThisWorkbook.Path & "\"
cFile = Dir(cPath & "*.doc?")
Set WordApp = CreateObject("word.Application")
Set str1 = Sheets("sheet1").Range("d1")
Do While cFile <> ""
Set wordD = WordApp.Documents.Open(cPath & cFile)
i = i + 1
With wordD.Tables(1)
If wordD.Tables(1).Select.Find.Execute(str1) <> False Then '要求对象?
h = .RowIndex
l = .ColumnIndex
End If
End With
wordD.Close
cFile = Dir
Loop
Set wordD = Nothing
WordApp.Quit
MsgBox h & l
End Sub
这段代码也是不行 |
|