Using the free zip library in VBA

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!

4 comments

  1. The VBA Editor is showing me 2 errors:

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

    1. 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.

      1. 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

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.