我一直在挠这个头。通常我会因为一些愚蠢的语法或缺少空格而找到答案,但这使我感到困惑
我以前在其他访问数据库中使用过“ Shell”功能来打开文件夹,我打算使用相同的代码结构来执行相同的操作,但是现在我不断收到“错误的过程调用或错误代码5”的错误代码。论点”
使用如下shell函数:
Dim FreightFile_Path As String
FreightFile_Path = "S:\Supply Chain\Freight"
Shell "explorer.exe" & " " & FreightFile_Path, vbNormalFocus
我已经尝试过双引号和它们周围的Chr(34),我将在代码部分中进行张贴。我还从字面上将代码从一个数据库(该数据库可以工作)复制到另一个数据库,并且对我出错。
我是否缺少一些需要在ms Access中激活才能使Shell
功能正常工作的东西?我已经在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 Chain\Freight"
Shell "explorer.exe " & FreightFile_Path, vbNormalFocus
重新启动应用程序,重新启动计算机;没有一个起作用。
答案 0 :(得分:1)
我只是遇到了同样的问题。就我而言,事实证明是反病毒阻止了Shell
。碰巧的是,IT为我的计算机设置了一个数据库的例外,但没有另一个数据库。有关更多详细信息,请参见my question and answer。
答案 1 :(得分:0)
尝试一下:
FreightFile_Path = "S:\Supply Chain\Freight"
Shell "cmd /c start explorer.exe """ & FreightFile_Path & """"
这是一种解决方法,但它可以工作...
答案 2 :(得分:0)
新尝试。使用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 Chain\Freight"
ShellEx "c:\windows\explorer.exe", """" & FreightFile_Path & """"
End Sub
答案 3 :(得分:0)
谢谢大家的帮助。这可能并不是真正解决Shell
问题的答案,但是它将用于打开文件路径。
Dim FreightFilePath As String
FreightFilePath = "S:\Supply Chain\Freight"
Application.FollowHyperLink FreightFilePath