Is there a way via VB/VBA to go through a folder containing numerous zip files, and return the number of files contained in each zip file?
I would prefer not having to manually open each zip file.
Thanks,
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Counting Zip File Contents
Is there a way via VB/VBA to go through a folder containing numerous zip files, and return the number of files contained in each zip file?
I found some code samples, but they were not in VB so I’m not sure which library to add. Just using Object makes it it difficult to discover the relevant properties and methods.
This code displays the count of the top level of the ZIP file. However, it does not traverse all of the folders in the archive, so that may understate the contents. (Or, since it displays the count for either a folder or a file, it might overstate the count. More work obviously is needed on this…)
Sub EnumerateZip() Dim sh As Object, fld As Object Set sh = CreateObject("Shell.Application") Set fld = sh.namespace("c:testingOpen_in_Fx.zip") MsgBox "Items: " & fld.items.Count 'Stop 'View Locals window Set fld = Nothing Set sh = Nothing End Sub
Oh, I think I found something that might help up on MSDN: Folder Object.
Hopefully you can find some pre-baked code that handles this easily.
Your code did the trick.
Thanks.
I found some code samples, but they were not in VB so I’m not sure which library to add. Just using Object makes it it difficult to discover the relevant properties and methods.
This code displays the count of the top level of the ZIP file. However, it does not traverse all of the folders in the archive, so that may understate the contents. (Or, since it displays the count for either a folder or a file, it might overstate the count. More work obviously is needed on this…)
Code:Sub EnumerateZip() Dim sh As Object, fld As Object Set sh = CreateObject("Shell.Application") Set fld = sh.namespace("c:testingOpen_in_Fx.zip") MsgBox "Items: " & fld.items.Count 'Stop 'View Locals window Set fld = Nothing Set sh = Nothing End SubOh, I think I found something that might help up on MSDN: Folder Object.
Hopefully you can find some pre-baked code that handles this easily.
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications