|
将就用下吧,函数如下:
- Function isExists(ByVal rng As Range, Optional ByVal strExtName As String = ".pdf") As String
- Dim fso As New FileSystemObject
- Dim fd As Folder
- Dim fl As File
- Dim strFileName As String
- Dim strExists As String
- strExists = ""
- For Each fd In fso.GetFolder(ThisWorkbook.Path).SubFolders
- For Each fl In fd.Files
- strFileName = Mid(fl, InStrRev(fl, "") + 1, Len(fl) - InStrRev(fl, "") - Len(strExtName))
- If rng.Value = strFileName Then
- strExists = fl
- Exit For
- End If
-
- Next
- Next
- isExists = strExists
- End Function
复制代码
将鼠标移动到函数所在的单元格,出现手型鼠标的时候,点击单元格即可
在弹出的警告栏上选择“是”,然后就可以打开文件了。
具体见附件:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|