Sub 查找()
Dim FindString As String, FindRange As Range
FindString = InputBox("请输入查找字符串:", "查找")
If FindString = "" Then Exit Sub
Set FindRange = Cells.Find(What:=FindString, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, MatchByte:=False, SearchFormat:=False)
If Not FindRange Is Nothing And FindRange.Value <> FindString Then
Do
Set FindRange = Cells.FindNext(FindRange)
Loop While FindRange.Value <> FindString
End If
FindRange.Activate
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
End Sub
思路:先用InputBox输入查找值,找到完全匹配的单元格后,通过激活超链接,自动打开链接的文档。
打开文档时系统会提示你注意链接数据源的安全,忽略就是。