MS Access VBA Shell:UNZIP

问题描述 投票:0回答:1

我正在使用从WScript.Shell调用的简单ZIP / UNZIP实用程序(http://infozip.sourceforge.net/)。

strPath = CurrentProject.Path & "\Backend_Databases\"
strPathUtil = CurrentProject.Path & "\Backend_Databases\DB_Utilities\"

ChDir strPath
strCMD = strPathUtil & "UNZIP.exe -o Item_4892.zip"
fShellRun (strCMD)

我没有得到任何结果,也没有抱怨这种方法。生成的strCMD如下所示:

C:\Users\Mark\Desktop\Backend_Databases\DB_Utilities\UNZIP.exe -o Item_4892.zip

此行与命令窗口完全按预期方式工作。 fShellRun正如我在AccessDB中使用的其他Shell命令所期望的那样工作。

注意:我可以发誓,这在上周初期测试期间就像上周一样,但我现在似乎无法解决这个问题。它让我完全邋!!也许我离这个太近了,我错过了一些明显的东西。

有任何想法吗?

vba ms-access access-vba
1个回答
0
投票

以下作品。我的原始fShellRun很久以前就被定制用于其他目的,并且与此任务不兼容。

以下是非常简单和功能,默默运行:

Private Sub UnzipTest_Click()

Dim oShell
Dim strFile As String
Dim strPath As String
Dim strPathUtil As String

Set oShell = CreateObject("WScript.shell")

strFile = Me!txtFilename
strPath = CurrentProject.Path & "\Backend_Databases\"
strPathUtil = CurrentProject.Path & "\Backend_Databases\DB_Utilities\"

strCMD = strPathUtil & "UNZIP.exe -o " & strPath & strFile & " -d " & strPath

oShell.Run strCMD, 0, True

Set oShell = Nothing

End Sub

注意:这指向第三方UNZIP实用程序,而不是std Windows ZIP实用程序。 UNZIP.exe保存在我的“... \ DB_Utilities”文件夹中。 http://infozip.sourceforge.net/

© www.soinside.com 2019 - 2024. All rights reserved.