我在其他 Access 数据库中使用了 "Shell" 函数来打开文件夹.
使用相同的代码结构,我得到
5 "无效的过程调用或参数"的错误代码
使用外壳函数如下:
Dim FreightFile_Path As String
FreightFile_Path = "S:Supply ChainFreight"
Shell "explorer.exe" & " " & FreightFile_Path, vbNormalFocus
我尝试了双引号和 Chr(34( 周围的.
我将代码从一个数据库(它在其中工作(复制到另一个数据库,结果出错。
我是否缺少需要在 MS Access 中激活的内容?我检查了 VBA 中的引用并确保它们匹配。
我尝试过的事情:
Call Shell("explorer.exe" & " " & Chr(34) & "S:Shared" & Chr(34),
vbNormalFocus)
Shell "explorer.exe " & Chr(34) & FreightFile_Path & Chr(34), vbNormalFocus
Shell "explorer.exe" & " " & FreightFile_Path, vbNormalFocus
Dim retVal
retVal = Shell("explorer.exe" & " " & FreightFile_Path, vbNormalNoFocus)
Dim i As String
i = "explorer.exe" & " " & FreightFile_Path
Shell i, vbNormalFocus
FreightFile_Path = "S:Supply ChainFreight"
Shell "explorer.exe " & FreightFile_Path, vbNormalFocus
重新启动应用程序,重新启动计算机。
我刚刚遇到了同样的问题。 就我而言,事实证明是防病毒软件阻止了Shell
。 碰巧的是,IT 部门为我的计算机设置了一个数据库的例外情况,而不是另一个数据库。 有关更多详细信息,请参阅我的问题和答案。
试试这个:
FreightFile_Path = "S:Supply ChainFreight"
Shell "cmd /c start explorer.exe """ & FreightFile_Path & """"
这是一种解决方法,但它有效...
新尝试。使用 WinAPI 调用
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal lpnShowCmd As Long) As Long
Public Sub ShellEx(ByVal Path As String, Optional ByVal Parameters As String, Optional ByVal HideWindow As Boolean)
If Dir(Path) > "" Then
ShellExecute 0, "open", Path, Parameters, "", IIf(HideWindow, 0, 1)
End If
End Sub
Sub Test()
FreightFile_Path = "S:Supply ChainFreight"
ShellEx "c:windowsexplorer.exe", """" & FreightFile_Path & """"
End Sub
谢谢大家的帮助。这可能不是Shell
问题的答案,但它适用于打开文件路径。
Dim FreightFilePath As String
FreightFilePath = "S:Supply ChainFreight"
Application.FollowHyperLink FreightFilePath