Reputation: 474
This seems like a question with an easy solution, but I searched the site (and web) for solution and I did not find any.
In order to open a zip file I'm using the following code:
Set zipApp = CreateObject("Shell.Application")
zip_file_count = zipApp.NameSpace("c:\1.zip").Items.Count
MsgBox zip_file_count
when c:\1.zip is an existing zip file (with one file inside). So my expectations where to see a msg box with "1", instead I get "the system could not find the file specified" even that the file exist (if I try to do in windows Run> c:\1.zip it works)
I also use this code to open a zip I just created and still get the same error.
Is there something I am missing?
btw, I'm using windows XP is the operating system is somehow relevant.
Upvotes: 0
Views: 321
Reputation: 70923
For me, it works IF the following changes are made
set zip_file_count = zipApp.NameSpace("c:\1.zip").Items.Count
^^^
What you are retrieving is the count of files, not a object reference, so, this set
is incorrect and should be removed.
BUT i did not get a "the system could not find the file specified" error but an "object required".
edited under the assumption that the .zip
file is accesible and not corrupt, the only way i have found to get the reported error has been to unregister the zip folder support. And the problem is corrected reregistering it again. So, you need the zipfldr.dll
file present in your %systemroot%\system32
folder and to register it with
regsvr32 "%systemroot%\system32\zipfldr.dll"
Upvotes: 2
Reputation: 38745
You won't see a message box with "1", but an "Object required" error, because zip_file_count should hold a number, not an object, so
set zip_file_count = zipApp.NameSpace("c:\1.zip").Items.Count
should be
zip_file_count = zipApp.NameSpace("c:\1.zip").Items.Count
As you didn't report this error, the code you run isn't the code you posted.
Without the Set and given an accessible .zip file, the code you posted 'works'. So double check "c:\1.zip" and its properties/rights.
Upvotes: 0