zipfldr.dll - Zipping files with WITHOUT using WINZIP

bill

Well-known Member
Joined
Mar 7, 2002
Messages
550
Hello,
On your desktop, you can right-click a file and SEND TO and one of your options is 'Compressed (zipped) Folder'.

Hack your registry for the above string and you'll find it associated with system32/zipfldr.dll.

So I'm wondering if one can instanciate the DLL in VBA to zip files.
(Can't add a direct reference to it in the VBE.)

My users DO NOT want to use WINZIP but instead wnat to use the functionality provided them from a clean install of XP....

Thanks!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
First, in order to save others the same questions I had about bill's code.
To get the files back out of the zip, simply create a second namespace and use the copyto method

Sub UnZip_File()
Dim ZipFle As Object
Dim TargFolder As Object

Set ZipFle = CreateObject("Shell.Application")
Set TargFolder = CreateObject("Shell.Application")

TargFolder.Namespace("Folder to copy zip contents to").CopyHere _
TargFolder.Namespace("Path To Zip File").items

Set TargFolder = Nothing
Set ZipFle = Nothing
End Sub

I did not text that exact code, obviously, there's no paths, but the conept works.

The major problem with this solution is that either the ZIPFLDR.DLL or the SHELL32 creates entries in %TEMP%, and it does not clean up after itself. When you reach 99 temp folders under %TEMP% the code will stop working. You have to do the cleanup yourself.
The entries it creates will be folder that are named
Temporary Folder [X] for ZIPFILENAME.ZIP
Where X is a number from 1 to 99
and ZIPFILENAME.ZIP is the name of the zip file you are extracting contents from.

Hopefully that helps, I stopped using this in my applications, instead I am using ZIP32/UNZIP32..
 
Upvote 0
Code:
        Dim shl As Object = CreateObject("Shell.Application")
        For Each fi As Object In shl.NameSpace("c:\temp\test.zip").Items
            shl.NameSpace("c:\").CopyHere(fi)
        Next
 
Upvote 0
And an easier way to create an empty zip:
(need to use Imports System.IO)

Code:
[COLOR=darkslategray]   Sub createEmptyZip(ByVal zipPath As String)[/COLOR]
[COLOR=darkslategray]       Dim arrHex() As Integer = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}[/COLOR]
[COLOR=darkslategray]       Dim sBin As String = ""[/COLOR]
[COLOR=darkslategray]       For i = 0 To arrHex.Count - 1[/COLOR]
[COLOR=darkslategray]           sBin += Chr(arrHex(i))[/COLOR]
[COLOR=darkslategray]       Next[/COLOR]
[COLOR=darkslategray]       File.WriteAllText(zipPath, sBin)[/COLOR]
[COLOR=darkslategray]   End Sub[/COLOR]
 
Upvote 0
Hm, seems to give me a null error on the namespace part when I don't include the shell control and automation reference.

Imports Shell32

Dim shl as New Shell

Code:
        Dim shl As Object = CreateObject("Shell.Application")
        For Each fi As Object In shl.NameSpace("c:\temp\test.zip").Items
            shl.NameSpace("c:\").CopyHere(fi)
        Next
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,565
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top