Search code examples
ms-accessvbalzma

LZMA Compression For VB6/VBA?


Looking to LZMA compress encrypted files in my Access 2000 application. Does anyone know the simplest way to do this in VB6/VBA or know of any source code?


Solution

  • You say you want to compress encrypted files? Compressing encrypted files usually doesn't result in much space saving as the encryption process scrambles the repeating structures that compression works on. So I assume you mean compress and encrypt files.

    There is a 7-zip lzma SDK but you'd need to compile the code and work out how to turn it into a windows dll or something you can use.

    I suggest you just push the task out to a command line i.e.

    Sub test()
        Dim ProgramTaskID As Double
        ProgramTaskID = Shell("c:\compress.bat c:\source.txt c:\dest.zip", VbAppWinStyle.vbNormalFocus)
    End Sub
    

    You don't need to create a batch file for this, you could supply the command directly. The Shell function will return as soon as the program has launched, so you will need to wait and test for the output file to appear before you try and do anything with it.

    7-zip is free and provides a command line syntax that you could use.