Beste helpers,
Met onderstaande code probeer ik een bestandenmap te zippen.
Krijg echter steeds de foutmelding: Fout 9 Objectvariabele of blokvariabele with is niet ingesteld.
op de regel: ShellApp.Namespace(zippedFileFullName).CopyHere ShellApp.Namespace(folderToZipPath).items
Sub test1()
Dim source, zipfile As String
source = "C:\Users\" & Environ("username") & "\Desktop\ZIPMAP\"
zipfile = Environ("TEMP") & "\ONDERHOUD_CV.zip"
CreateZipFile source, zipfile
End Sub
Sub CreateZipFile(folderToZipPath As Variant, zippedFileFullName As Variant)
Dim ShellApp As Object
'Create an empty zip file
Open zippedFileFullName For Output As #1
Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
Close #1
'Copy the files & folders into the zip file
Set ShellApp = CreateObject("Shell.Application")
ShellApp.Namespace(zippedFileFullName).CopyHere ShellApp.Namespace(folderToZipPath).items
Do Until ShellApp.Namespace(zippedFileFullName).items.Count = ShellApp.Namespace(folderToZipPath).items.Count
Application.Wait (Now + TimeValue("0:00:01"))
Loop
End Sub
Heeft iemand een oplossing ?