Run-time error 91 (1 Viewer)

Lrn2Code

Registered User.
Local time
Today, 11:02
Joined
Dec 8, 2008
Messages
56
Hello All,

I'm still trying to figure out my unzip files code that doesn't want to work. Am not sure if the "file exists error" is gone because I can't get that far into the code. Now the problem is I am getting run time error 91 "Object variable or With block variable not set" on the unzip code.
I don't understand what that message means.

Have pasted the code below with the error line highlighted in red.

What am I missing? This is driving me nutz!

Thanks for your help.

Dim cFileZip As Variant
Dim cDestination As String
Dim o As Object
Dim ofile As Object


cFileZip = "C:\Stat\FY09\ToImport\FilesforDOE.Zip"
cDestination = "C:\Stat\FY09\ToImport\FilesforDOE\"
'cDestination = cDestination + "\" + "FilesforDOE\"


Set o = CreateObject("shell.application")
For Each ofile In o.Namespace(cFileZip).items
o.Namespace(cDestination).copyfile(ofile).items
Next
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 16:02
Joined
Sep 12, 2006
Messages
15,709
vba seems to lose context on stuff like this

eg with iterating tabledefs you seem to get exactly the same problem if you just say

Code:
dim tdf as tabledef
for each tdf in currentdb.tabledefs
next

you have to say

Code:
dim tdf as tabledef
dim db as database

[COLOR="Red"]set db=currentdb[/COLOR]
for each tdf in [COLOR="red"]db.[/COLOR]tabledefs
next

i suspect the same thing applies,

and you have to instantiate
o.Namespace(cFileZip) with a suitable object.

I hope that makes sense
 
Last edited:

Lrn2Code

Registered User.
Local time
Today, 11:02
Joined
Dec 8, 2008
Messages
56
Thanks Gemma. I get the current db thing - that makes sense - but am not sure how to reference that o.Namespace stuff.


I tried to Dim Namespace as Object and then tried Variant and neither seemed to make a difference.


Now with the o.db.NameSpace(cDestination).copyhere (ofile)
line of code I get a run-time error 438 "Object doesn't support this property or method".

Another thing that probably makes a huge difference is that these files are being unzipped from one folder into another prior to being imported into the database. So that would eliminate the need for the db at this point (right?) but shouldn't there be some other variable to differentiate the documents being unzipped are copied into a different file directory? Or does that make sense?

Sometimes this stuff is clear as mud to me.
 
Last edited:

Users who are viewing this thread

Top Bottom