Using the free zip library in VBA

Software

In a previous post I briefly explained how you can compile the free zlib library with Visual 2013 Studio and produce a 32 and a 64 bits dll that you can then use in VBA (Word, Excel, Access, etc…). If you follow this link to the article, you can even download the binaries I baked.

However, to use these dlls in a real world project, we need to wrap them in some 32/64 bits VBA code.
Inspired by samples I found on the web, here a quickly reusable module for your VBA projects.
Look at the TestXXXX procedures (change the pathes and filenames, of course, and execute them in the immediate window) for some samples.

Enjoy!

 

 

Comments on this entry are closed.

  • Peter

    The VBA Editor is showing me 2 errors:

    line 059: mlErr = 0&
    line 192: lIntSize = lFlags And 3&;

    • franchsesko

      Hi Peter,
      Sorry for that and thank you for pointing this out.
      The code renderer I use on this blog sometimes messes with my “&” signs, I’ll try to correct that.
      So, the lines should read:
      059: mlErr = 0&
      192: lIntSize = lFlags And 3&
      In both lines, the “&” after the number indicates a VB/A “Long” value (which is a 32bits signed value)
      Francesco.

      • Peter

        Hi Francesco, thank you for the correction.

        I came along your example while searching for a solution to zip files in MS Excel VBA under OS X. – I never was a mac user but I think, I can’t use dlls on that operating system… Do you have experience in macOS and an idea to achieve this on that os too?

        Just asking… 🙂
        Peter