在 Access 中,如何打开只知道部分文件夹名称的 Windows Explorer 文件夹?
From Access, how do I open a Windows Explorer folder knowing only part of the folder name?
我不完整的文件路径存储在Me!txtFilePath
中。它包含文件夹位置的完整路径和文件夹名称的 ~30 个字符中的前 9 个字符。前 9 个字符保证是唯一的。目前我有一个按钮,在单击时执行以下代码:
Shell "explorer """ & Me!txtFilePath & "", vbNormalFocus
如果我不知道文件夹名称的最后几个字符,我如何确保它打开正确的文件夹?谢谢!
编辑:我正在尝试打开一个我没有 "drive" 的网络文件夹。
我不确定为什么这个解决方案对我有用,而建议却没有,但我找到了答案。大部分问题都是由评论者对我的原创 post 解决的 - 感谢你们所有人。
基本上,我必须设置一个等于 Dir
值的字符串变量。 Dir
仅 returns 文件夹名称的结尾部分,而不是整个路径,因此在打开文件时我需要将其与路径名称的已知开头结合起来。我还必须使用 Application.FollowHyperlink
而不是 Shell
。我不知道为什么,我不知道是否有任何缺点。也许 Shell explorer
只适用于文件,不适用于文件夹。
Private Sub btnJobFile_Click()
Dim strStartFilePath As String
Dim strEndFilePath As String
strStartFilePath = "\JobFolders" & Me!txtFilePath
strEndFilePath = Dir(strStartFilePath & Me.JobNum & "*", vbDirectory)
Application.FollowHyperlink strStartFilePath & strEndFilePath
End Sub
我不完整的文件路径存储在Me!txtFilePath
中。它包含文件夹位置的完整路径和文件夹名称的 ~30 个字符中的前 9 个字符。前 9 个字符保证是唯一的。目前我有一个按钮,在单击时执行以下代码:
Shell "explorer """ & Me!txtFilePath & "", vbNormalFocus
如果我不知道文件夹名称的最后几个字符,我如何确保它打开正确的文件夹?谢谢!
编辑:我正在尝试打开一个我没有 "drive" 的网络文件夹。
我不确定为什么这个解决方案对我有用,而建议却没有,但我找到了答案。大部分问题都是由评论者对我的原创 post 解决的 - 感谢你们所有人。
基本上,我必须设置一个等于 Dir
值的字符串变量。 Dir
仅 returns 文件夹名称的结尾部分,而不是整个路径,因此在打开文件时我需要将其与路径名称的已知开头结合起来。我还必须使用 Application.FollowHyperlink
而不是 Shell
。我不知道为什么,我不知道是否有任何缺点。也许 Shell explorer
只适用于文件,不适用于文件夹。
Private Sub btnJobFile_Click()
Dim strStartFilePath As String
Dim strEndFilePath As String
strStartFilePath = "\JobFolders" & Me!txtFilePath
strEndFilePath = Dir(strStartFilePath & Me.JobNum & "*", vbDirectory)
Application.FollowHyperlink strStartFilePath & strEndFilePath
End Sub