![]() Private Const FORMAT_MESSAGE_TEXT_LEN = &HA0 Private Const FORMAT_MESSAGE_MAX_WIDTH_MASK = &HFF Private Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200 Private Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000 Private Const FORMAT_MESSAGE_FROM_STRING = &H400 Private Const FORMAT_MESSAGE_FROM_HMODULE = &H800 Private Const FORMAT_MESSAGE_ARGUMENT_ARRAY = &H2000 Private Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100 'Private Const PROCESS_QUERY_INFORMATION As Long = (&H400) Private Const PROCESS_VM_READ As Long = (&H10) Private Const TOKEN_READ As Long = (STANDARD_RIGHTS_READ Or TOKEN_QUERY) Private Const STANDARD_RIGHTS_READ As Long = (READ_CONTROL) Private Const READ_CONTROL As Long = &H20000 Private Const TOKEN_QUERY_SOURCE As Long = &H10 ' Used By OpenProcessToken and OpenProcess Private Const S_FALSE As Long = &H1 ' odd but true that S_FALSE would Private Const E_INVALIDARG As Long = &H80070057 Private Declare Function FormatMessage Lib "kernel32" _ Private Declare Function GetUserProfileDirectory Lib "userenv.dll" Alias Private Declare Function SHGetFolderPath Lib "shell32.dll" Alias Private Declare Function OpenProcessToken Lib "advapi32.dll" ( _ Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Private Declare Function GetCurrentThread Lib "kernel32" () As Long Private Declare Function OpenProcess Lib "kernel32" ( _ Private Declare Function CloseHandle Lib "kernel32" _ Public Const PROCESS_QUERY_INFORMATION = &H400 Public Const gsAPP_TITLE As String = "Application Title" ' These functions are used to retrieve folder names that are specific the ' GetSpecialFolder which returns a specific folder for the ' GetUserProfileFolder which returns the folder in which the ''' it the zip code is finished and run your other code. ''' You need the ShellAndWait function to wait until ''' The examples use shell to run the winzip32.exe file. ''' Module Purpose: This Module holds 'Get User Directory' sample Need (but and all you need), but this complete is in function, andĬontains 'UnZip_ZipFile' procedure by Ron de Bruin as you have. In the following code there are more constants and procedures then you You can then copy the line to the clipboard, and paste it into a "command window" so that you can execute the command manually and see the error messages. Which will put a copy of the command line into the Immediate Window below your code. This will enable you to identify all the problems with your command line. Which will display the command line and pause until you click the OK button. I suggest that you add a "debugging" statement immediately after the statement that creates the value in ShellStr, so that you can see the command line you have created. It's not at all clear what you intended those text strings to do (the documentation for WZUNZIP doesn't include the options you are using, but perhaps older versions of WINZIP recognize them). You are missing a delimiter between the path for the executable and the name of the executable, and you have a couple of text strings that contain spaces. ![]() However, to address your specific question, the value in ShellStr has a number of problems. Instead you must download and install the WinZip? Command Line Support Add-On, which includes the WZZIP and WZUNZIP command-line applications. Modern versions (I checked version 15) cannot be used from the command line. I'm not sure what version of WinZip you are using. & ""FE Folder"" & Chr(34) & strTargetFolder & Chr(34)įileCopy strTargetFolder & Dir(strTargetFolder), strTargetFolder & strTargetFile ShellStr = PATHWINZIP & ""Winzip32 -min -e"" _ 'Unzip the zip file in the folder FolderName MsgBox ""Please find your copy of winzip32.exe and try again"" If Dir(PATHWINZIP & ""winzip32.exe"") = """" Then 'This will check if this is the path where WinZip is installed. ![]() Private Sub UnZip_ZipFile(strZippedFileName As String, strTargetFolder As String, Optional strTargetFile As String)Ĭonst PATHWINZIP As String = ""C:program files"" I am encountering some confusion with one of my string paths the extraction destination I believe is where the error is occurring. I plan on putting this procedure behind a button in a form. I have some code and hoping someone could point me in the right direction of successfully implementing it(yes, I have tagged the author in my procedure :-). I am seeking a solution to extract a zip file using VBA code. ![]()
0 Comments
Leave a Reply. |