使用文件路径中的空格调用shell

时间:2014-02-02 02:30:11

标签: shell vba zip unzip

下面的代码使用winzip解压缩.zip文件。但是,如果FolderPath包含空白,我会收到“无法打开文档”的不可捕获错误,没有错误编号。如果FolderPath包含空白,如何用Shell解压缩此文件?谢谢,

 FolderPath = ThisWorkbook.Path & "\"

 Unzipfile = Dir(FolderPath & "*.zip")
 While UnzipFile <> ""
 if InStr(1, UnzipFile, ".zip") > 0 Then
 ShellStr = "C:\Program Files\WinZip\winzip32 e- " & FolderPath & UnzipFile & " " & FolderPath
 Call Shell(ShellStr, vbHide)

1 个答案:

答案 0 :(得分:0)

您需要引用带空格的路径

ShellStr = """C:\Program Files\WinZip\winzip32.exe"" e- """ & _
            FolderPath & UnzipFile & """ """ & FolderPath & """"
相关问题