MikeC14081972
Programmer
Hi,
I have been using the below code successfully for a while in Access 2003, however I'm unable to get it to run in 2007 (Code example has been cut down to save space)
The code will run and create the required zip folder but will not move files to the folder and I'm receiving the following error
Run-time error '91':
Object variable or with block not set
on the following line of code
I can add files manually to the zip folder so I know the issue doesn't lie there.
Has anyone got any ideas why this would be happening?
Thanks in Advance
I have been using the below code successfully for a while in Access 2003, however I'm unable to get it to run in 2007 (Code example has been cut down to save space)
Code:
Function Zip(fPath, ToAttach As String)
Dim oApp As Object
Dim Attach As Variant
Dim i As Integer
CreateZip (fPath)
Set oApp = CreateObject("Shell.Application")
Attach = Split(ToAttach, ";")
For i = LBound(Attach) To UBound(Attach) - 1
oApp.Namespace(fPath).CopyHere Attach(i)
Next i
Set oApp = Nothing
End Function
Function CreateZip(zPath)
Dim fso As FileSystemObject
Dim arrHex, sBin, i
On Error GoTo ErrHandler
Set fso = 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 fso.CreateTextFile(zPath, True)
.Write sBin
.Close
End With
exit function
The code will run and create the required zip folder but will not move files to the folder and I'm receiving the following error
Run-time error '91':
Object variable or with block not set
on the following line of code
Code:
oApp.Namespace(fPath).CopyHere Attach(i)
I can add files manually to the zip folder so I know the issue doesn't lie there.
Has anyone got any ideas why this would be happening?
Thanks in Advance