Reputation: 232
Hey my program checks for a zip file and copies it to another directory. However I stumbled upon "Run time error '91' object variable or With block variable not set" on oApp when I compiled it.
Sub UnZip(Fname As Variant)
Dim oApp As Object
Dim FileNameFolder As Variant
FileNameFolder = "P:\"
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname).items
End Sub
What's the problem?
I'm using MS access 2010
Upvotes: 2
Views: 1291
Reputation: 6761
.Copyhere works on folder objects.
Sub UnZip(Fname As Variant)
dim objShell
dim objFolder
set objShell = CreateObject("shell.application")
set objFolder = objShell.NameSpace("P:")
If not objFolder is nothing then
objFolder.CopyHere(Fname)
End If
End Sub
Fname must include both path and filename with extension.
Upvotes: 1