Auto-ZIP files from Access

B

Bill Sturdevant

Does anyone know if it is possible to put a file into a
zipo archive via code from within Access?
 
P

PC Datasheet

Yes! You need to go tothe WinZip website and download the WinZip Command Line
Utility.
 
B

Bill Sturdevant

Can you supply an example?
-----Original Message-----
Yes! You need to go tothe WinZip website and download the WinZip Command Line
Utility.


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com





.
 
P

PC Datasheet

Bill,

There's documentation on how to do it at the website to download or I can do it
for you for a reasonable fee. Email me at (e-mail address removed).
 
S

Stephen Lebans

I just cut this out of an older compression development progr of mine(in
VB) but it will give you the general idea.

Const SYNCHRONIZE = &H100000


Const INFINITE = &HFFFF
'Wait forever

Const WAIT_OBJECT_0 = 0
'The state of the specified object is signaled

Const WAIT_TIMEOUT = &H102
'The time-out interval elapsed & the object's state
'is nonsignaled.


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 Declare Function CloseHandle Lib "kernel32" (ByVal hObject As
Long) As Long
Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)



Private Function RunZip(fname As String, ctr As Long)
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
Dim lngTemp As Long
Dim s As String
Dim s1 As String
Dim level As Long

s = "C:\Program Files\Winzip\wzzip.exe -a -ex -ybc "
s1 = s & ctr & "Level" & ".zip" & " " & fname
lPid = Shell(s1, vbHide) ' vbNormalFocus) ' vbhide
If lPid <> 0 Then
'Get a handle to the shelled process.
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)
'If successful, wait for the application to end and close the
handle.
If lHnd <> 0 Then
lRet = WaitForSingleObject(lHnd, INFINITE)
CloseHandle (lHnd)
End If
'MsgBox "Just terminated.", vbInformation, "Shelled Application"
End If


RunZip = ctr & "Level" & ".zip"

' *********************************************************
' DEBUG.. PUT THIS BACK IN!!!!!!!!!!!!
' no looked after in calling function
Kill fname
'Debug.Print "Level:" & ctr

Dim strTemp As String
Dim ZipFileLength As Long
ZipFileLength = FileLen(ctr & "Level" & ".zip")
strTemp = ""

strTemp = strTemp & "ZIP FileName:" & ctr & "Level" & vbTab & vbTab &
"Size:" & vbTab & ZipFileLength & vbCrLf
strTemp = strTemp & "---------------------------------------------" &
vbCrLf
strTemp = strTemp & "Savings:" & OrigFileLength & vbTab & "-" &
ZipFileLength & vbTab & "=" & vbTab & vbTab & OrigFileLength -
ZipFileLength & vbCrLf

strTemp = strTemp & "*********************************************" &
vbCrLf
'strTemp = strTemp & vbCrLf

'strTemp = strTemp & "Highest Reps:" & lngHigh & vbCrLf


Me.txtLog.Text = Me.txtLog.Text & strTemp
Me.txtSummary.Text = ctr & "Level" & ".zip"
End Function


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top