Can anyone please advise how I can get the line containing Namespace working in the code below? Does it need a Declaration or Reference file, whatever?

I always get r-time error 91: "Object variable not set or With block not set"

any suggestions, ideas or advice gratefully received.



 
Public Function Unzip(DefPath, Fname)
'Unzips A File
'Fname must be FULL Path\Filename.zip
'DefPath must be valid Path you want to Unzip file TO
Dim FSO As Object
Dim oApp As Object
On Error GoTo UnZip_Err:
 
Set oApp = CreateObject("Shell.Application")
 
'Copy the files in the newly created folder
oApp.Namespace(DefPath).CopyHere oApp.Namespace(Fname).items <<<<
 
On Error Resume Next
Set FSO = CreateObject("scripting.filesystemobject")
FSO.deletefolder Environ("Temp") & "\Temporary Directory*", True
Set oApp = Nothing
Set FSO = Nothing
Exit Function