Beste redacteur,
Kan je aub de syntaxis leveren want handmatig zippen begrijp ik. Ik wil juist een bestand zippen dat vanuit de syntaxis uitgevoerd wordt. De shell comando heb ik onderzocht maar kan niet vinden over zippen.
Aub wil jij zo vriendelijk even de betreffende syntaxis aan te leveren?
Ik heb een syntaxis hier ergens gevonden echter is dit vanuit Excel aangeroepen en niet vanuit Access.
Als ik dit uitvoert dan maakt hij alleen een zipbestand aan echter zipt hij niet test.xls in de zipfile.
Dim strDate As String, DefPath As String
Dim FileNameZip, FileNameXls
Dim oApp As Object
'If ActiveWorkbook Is Nothing Then Exit Sub
'DefPath = ActiveWorkbook.Path
DefPath = "C:\"
strEffe = "C:\test.xls"
If Len(DefPath) = 0 Then
MsgBox "Plz Save activeworkbook before zipping" & Space(12), vbInformation, "zipping"
Exit Sub
End If
'Create date/time string and the temporary xls and zip file name
strDate = Format(Now, " dd-mmm-yy h-mm-ss")
FileNameZip = DefPath & "test" & strDate & ".zip"
FileNameXls = DefPath & "test" & strDate & ".xls"
If Dir(FileNameZip) = "" And Dir(FileNameXls) = "" Then
'Make copy of the activeworkbook
'ActiveWorkbook.SaveCopyAs FileNameXls
'Create empty Zip File
newzip (FileNameZip)
strEffe = "C:\test.xls"
'Copy the file in the compressed folder
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameZip).CopyHere strEffe
'Keep script waiting until Compressing is done
'On Error Resume Next
'Do Until oApp.Namespace(FileNameZip).items.Count = 1
' Application.Wait (Now + TimeValue("0:00:01"))
'Loop
On Error GoTo 0
'Delete the temporary xls file
Kill FileNameXls
MsgBox "completed zipped : " & vbNewLine & FileNameZip, vbInformation, "zipping"
Else
MsgBox "FileNameZip or/and FileNameXls exist", vbInformation, "zipping"
End If