在过去的几天里,我一直在尝试使用Shell()
通过VBA打开文件我的问题是我的路径在路径中有括号:c:/ xxx /(xxx)/ xxx
任何帮助都将不胜感激,谢谢。
Sub OpenMyFolder()
Dim myFolder As String
myFolder = "C:\Users\MrSmith\Dropbox (Personal)\Photos\2018"
myFolder = myFolder & "\Jan"
Shell "explorer.exe" & " " & myFolder, vbNormalFocus
End Sub
答案 0 :(得分:0)
将任何带空格的路径传递给Shell时,应将其括在引号中:
Sub OpenMyFolder()
Dim myFolder As String
myFolder = "C:\Users\MrSmith\Dropbox (Personal)\Photos\2018"
myFolder = myFolder & "\Jan"
Shell "explorer.exe """ & myFolder & """", vbNormalFocus
End Sub
VBA字符串中的引号应该加倍以逃避它们(即所以引号不会被解释为字符串的开头/结尾)