I'm trying to compress an XML file into a ZIP file and I'm using the code below, but I'm running into the following error
Indicate the error on this line
Shell.Namespace(zipFile).CopyHere (xmlFile)
Code:
Sub CreateZipFile(BalanzaComprobacion As String)
Dim zipFile As String
Dim xmlFile As String
Dim Shell As Shell32.Shell
zipFile = "C:\XML\" & BalanzaComprobacion & ".zip"
xmlFile = "C:\XML\" & BalanzaComprobacion & ".xml"
NewZip (zipFile)
Shell.Namespace(zipFile).CopyHere (xmlFile)
End Sub
Sub NewZip(zipFile)
Dim oFSO, arrHex, sBin, i, Zip
Set oFSO = CreateObject("Scripting.FileSystemObject")
arrHex = Array(80, 75, 5, 6, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
For i = 0 To UBound(arrHex)
sBin = sBin & Chr(arrHex(i))
Next
With oFSO.CreateTextFile(zipFile, True)
.Write sBin
.Close
End With
End Sub