Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unzip file 1

Status
Not open for further replies.

jbpelletier

Programmer
Joined
Sep 8, 2001
Messages
232
Location
CA
i would like to unzip a file who contain only one text file for import into an access table via transfertext command..

The only prog that i have is winzip

how could i do it in vba code ??

any help apreciate

jb
 
there is an undocumented Command Line Interface (CLI) with Winzip.

Here is an example of how to use. I pass in the file path and file name to the sub so you will have to write it yourself.


Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Const SYNCHRONIZE = &H100000
Private Const INFINITE = -1&

Sub unzip(Tempstr As String, File As String)
Dim sPWZipPath, sCmdLine, sTargetPath, sSourceFile As String
Dim iRunTaskID As Integer
Dim hProc As Long

sPWZipPath = "C:\Program Files\winzip\winzip32.exe" 'Setup the needed paths
sTargetPath = "C:\" 'Path to unzip ZIP contents to
sSourceFile = Tempstr 'Source ZIP file
sCmdLine = sPWZipPath & " -min -e " & sSourceFile & " c:\" ' here is the winzipsetup and commands -min = minimized, -e =extract
iRunTaskID = Shell(sCmdLine, vbHide)
DoEvents
hProc = OpenProcess(SYNCHRONIZE, 0, iRunTaskID)
If hProc <> 0 Then
WaitForSingleObject hProc, INFINITE
CloseHandle hProc
End If

End Sub



Good luck hope it helps. There are many more commands that can go with the CLI for winzip.

To go where no programmer has gone before.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top