ZIP code module without DLL dependencies???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • The Frog

    ZIP code module without DLL dependencies???

    Hi Everyone,

    I am trying to find a solution for handling zipped data without the
    need to ship / install any DLL files with the database. Does anybody
    know of code to handle ZIP files that does not require any external
    references? If I can ship it 'built-in' as either a class module or
    standard module then that would be perfect.

    Any help would be greatly appreciated.

    Cheers

    The Frog
  • Tom van Stiphout

    #2
    Re: ZIP code module without DLL dependencies???

    On Mon, 19 Nov 2007 01:56:00 -0800 (PST), The Frog
    <Mr.Frog.to.you @googlemail.com wrote:

    That would require you to implement the zip file format and zip
    decompression in VBA. Good luck with that.

    -Tom.

    >Hi Everyone,
    >
    >I am trying to find a solution for handling zipped data without the
    >need to ship / install any DLL files with the database. Does anybody
    >know of code to handle ZIP files that does not require any external
    >references? If I can ship it 'built-in' as either a class module or
    >standard module then that would be perfect.
    >
    >Any help would be greatly appreciated.
    >
    >Cheers
    >
    >The Frog

    Comment

    • Stephen Lebans

      #3
      Re: ZIP code module without DLL dependencies???

      I cannot find it right now but I have downloaded a VB6 class that supports
      the ZIP file format. A Google search for "Zip Visual Basic class" should get
      you started.

      --

      HTH
      Stephen Lebans

      Access Code, Tips and Tricks
      Please respond only to the newsgroups so everyone can benefit.


      "The Frog" <Mr.Frog.to.you @googlemail.com wrote in message
      news:58cc3f9c-1b18-4e8a-bb8e-4613a683c48d@d6 1g2000hsa.googl egroups.com...
      Hi Everyone,
      >
      I am trying to find a solution for handling zipped data without the
      need to ship / install any DLL files with the database. Does anybody
      know of code to handle ZIP files that does not require any external
      references? If I can ship it 'built-in' as either a class module or
      standard module then that would be perfect.
      >
      Any help would be greatly appreciated.
      >
      Cheers
      >
      The Frog

      Comment

      • Chuck Grimsby

        #4
        Re: ZIP code module without DLL dependencies???


        Create, extract, or both?

        If the target machine is XP SP2, then all the DLLs you need are
        already installed.

        (Although to be honest, I've only does this with a VBScript file, not
        in VBA.)



        On Mon, 19 Nov 2007 01:56:00 -0800 (PST), The Frog
        <Mr.Frog.to.you @googlemail.com wrote:
        >I am trying to find a solution for handling zipped data without the
        >need to ship / install any DLL files with the database. Does anybody
        >know of code to handle ZIP files that does not require any external
        >references? If I can ship it 'built-in' as either a class module or
        >standard module then that would be perfect.
        >Any help would be greatly appreciated.
        Please Post Any Replies To This Message Back To the Newsgroup.
        There are "Lurkers" around who can benefit by our exchange!

        Comment

        • Tony Toews [MVP]

          #5
          Re: ZIP code module without DLL dependencies???

          Chuck Grimsby <c.grimsby@worl dnet.att.net.in validwrote:
          >
          >Create, extract, or both?
          >
          >If the target machine is XP SP2, then all the DLLs you need are
          >already installed.
          >
          >(Although to be honest, I've only does this with a VBScript file, not
          >in VBA.)
          Interesting. Got any URLs with VBScript code?

          Tony
          --
          Tony Toews, Microsoft Access MVP
          Please respond only in the newsgroups so that others can
          read the entire thread of messages.
          Microsoft Access Links, Hints, Tips & Accounting Systems at

          Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

          Comment

          • Chuck Grimsby

            #6
            Re: ZIP code module without DLL dependencies???

            On Tue, 20 Nov 2007 04:13:10 GMT, "Tony Toews [MVP]"
            <ttoews@teluspl anet.netwrote:
            >Chuck Grimsby <c.grimsby@worl dnet.att.net.in validwrote:
            >>Create, extract, or both?
            >>If the target machine is XP SP2, then all the DLLs you need are
            >>already installed.
            >>(Although to be honest, I've only does this with a VBScript file, not
            >>in VBA.)
            >Interesting. Got any URLs with VBScript code?
            I got the source for this somewhere in Usenet, although I've forgotten
            where. I have the full message, but it's on a Backup disk somewhere.
            (It's not exactly new!)

            Some who *really* knows VBScript could probably do a better job, but
            this works.

            This creates a Zip file and copies the contents of a whole folder into
            it. As always, watch out for word wrap....

            ---------------------- Cut Here ------------------------------------
            Option Explicit
            Dim ZipFileName, FolderToZip
            Dim oApp, MyHex, MyBinary, i
            Dim oFSO, oTF

            MyHex = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0,0, 0)
            For i = 0 To UBound(MyHex)
            MyBinary = MyBinary & Chr(MyHex(i))
            Next

            FolderToZip = "C:\Data Files\My Data\"
            ' in case someone forgets the last slash:
            If Right(FolderToZ ip, 1) <"\" Then
            FolderToZip = FolderToZip & "\"
            End If

            ZipFileName = "G:\Backups \" & _
            FormatNowISO & _
            "MyDataBackup.z ip"

            'Create empty Zip File
            Set oFSO = CreateObject("S cripting.FileSy stemObject")
            Set oTF = oFSO.CreateText File(ZipFileNam e, True)
            oTF.Write MyBinary
            oTF.Close
            Set oTF = Nothing
            Set oFSO = Nothing

            'Copy the files to the compressed folder
            Set oApp = CreateObject("S hell.Applicatio n")
            oApp.NameSpace( ZipFileName).Co pyHere _
            oApp.NameSpace( FolderToZip).it ems

            'Keep script waiting until Compressing is done
            On Error Resume Next
            Do Until oApp.NameSpace( ZipFileName).it ems.Count =
            oApp.NameSpace( FolderToZip).it ems.Count
            Application.Wai t (Now + TimeValue("0:00 :01"))
            Loop
            Set oApp = Nothing
            On Error GoTo 0

            'MsgBox "Done!" & vbnewline & _
            "You'll find the zipfile here: " & vbnewline & _
            ZipFileName

            WScript.Quit

            Function FormatNowISO
            FormatNowISO = DatePart("yyyy" , Now())
            FormatNowISO = FormatNowISO & Right("00" & DatePart("m", Now()), 2)
            FormatNowISO = FormatNowISO & Right("00" & DatePart("d", Now()), 2)
            ' if the time is needed:
            'FormatNowISO = FormatNowISO & _
            Right("00" & DatePart("h", Now()), 2)
            'FormatNowISO = FormatNowISO & _
            Right("00" & DatePart("n", Now()), 2)
            'FormatNowISO = FormatNowISO & _
            Right("00" & DatePart("s", Now()), 2)
            End Function
            ---------------------- Cut Here ------------------------------------

            I'll have to dig out the backup to get at a un-zip script. As I
            remember, it's pretty much the same thing, just copying the files out
            of the (zipped) folder. I'll see if I can dig it out over the
            Thanksgiving holiday.

            Please Post Any Replies To This Message Back To the Newsgroup.
            There are "Lurkers" around who can benefit by our exchange!

            Comment

            • Tony Toews [MVP]

              #7
              Re: ZIP code module without DLL dependencies???

              "Stephen Lebans" <ForEmailGotoMy .WebSite.-WWWdotlebansdot ...@linvalid.co mwrote:
              >A Google search for "Zip Visual Basic class" should get
              >you started.
              Nope. way too many hits without the quotes and way too few hits with the quotes.

              Tony
              --
              Tony Toews, Microsoft Access MVP
              Please respond only in the newsgroups so that others can
              read the entire thread of messages.
              Microsoft Access Links, Hints, Tips & Accounting Systems at

              Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

              Comment

              • Tony Toews [MVP]

                #8
                Re: ZIP code module without DLL dependencies???

                Chuck Grimsby <c.grimsby@worl dnet.att.net.in validwrote:
                >>Chuck Grimsby <c.grimsby@worl dnet.att.net.in validwrote:
                >>>Create, extract, or both?
                >>>If the target machine is XP SP2, then all the DLLs you need are
                >>>already installed.
                >>>(Although to be honest, I've only does this with a VBScript file, not
                >>>in VBA.)
                >
                >>Interesting . Got any URLs with VBScript code?
                >
                >I got the source for this somewhere in Usenet, although I've forgotten
                >where.
                Thanks but I suspect that could be quite difficult to convert to VB/VBA. I suspect
                that VBScripts opening of a .zip file is a lot more intelligent than would be
                VB6/VBA.

                Tony
                --
                Tony Toews, Microsoft Access MVP
                Please respond only in the newsgroups so that others can
                read the entire thread of messages.
                Microsoft Access Links, Hints, Tips & Accounting Systems at

                Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

                Comment

                • Stuart McCall

                  #9
                  Re: ZIP code module without DLL dependencies???

                  "Tony Toews [MVP]" <ttoews@teluspl anet.netwrote in message
                  news:vul7k35ggk a0h1vfjeaag88lf b0lhmdg0t@4ax.c om...
                  Thanks but I suspect that could be quite difficult to convert to VB/VBA.
                  I suspect
                  that VBScripts opening of a .zip file is a lot more intelligent than would
                  be
                  VB6/VBA.
                  Actually it wasn't too bad:

                  Sub CreateZip()
                  ZipFileName = "c:\temp\test1. zip"
                  FolderToZip = "c:\temp\testzi p\"

                  HexArray = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                  0, 0, 0, 0)
                  For i = LBound(HexArray ) To UBound(HexArray )
                  BinStr = BinStr & Chr(HexArray(i) )
                  Next
                  Open ZipFileName For Output As 1
                  Print #1, BinStr
                  Close 1

                  Set oApp = CreateObject("S hell.Applicatio n")
                  oApp.NameSpace( ZipFileName).Co pyHere oApp.NameSpace( FolderToZip).it ems
                  Do Until oApp.NameSpace( ZipFileName).it ems.Count =
                  oApp.NameSpace( FolderToZip).it ems.Count
                  DoEvents
                  Loop
                  Set oApp = Nothing
                  End Sub

                  Although I've yet to find a way to copy individual files into the zip, other
                  than creating a folder, copying the files into it, then specifying this as
                  the source folder for the copy (which could be done transparently, but it's
                  a bit kludgy).


                  Comment

                  • Tony Toews [MVP]

                    #10
                    Re: ZIP code module without DLL dependencies???

                    "Stuart McCall" <smccall@myunre albox.comwrote:
                    >Thanks but I suspect that could be quite difficult to convert to VB/VBA.
                    >I suspect
                    >that VBScripts opening of a .zip file is a lot more intelligent than would
                    >be
                    >VB6/VBA.
                    >
                    >Actually it wasn't too bad:
                    No, that wouldn't have been bad at all. However I'm slightly skeptical that the
                    VBScript object would work in all systems. While I doubt I have any Win 2000 clients
                    left there could be some. And I'm just a skeptic.

                    So I think I'll use the infozip dlls so long as they will work if copied into the
                    same folder as the FE MDE. I do not want to worry about them having to be installed
                    in the system32 folder.
                    >Although I've yet to find a way to copy individual files into the zip, other
                    >than creating a folder, copying the files into it, then specifying this as
                    >the source folder for the copy (which could be done transparently, but it's
                    >a bit kludgy).
                    Interesting that.

                    Thanks, Tony

                    --
                    Tony Toews, Microsoft Access MVP
                    Please respond only in the newsgroups so that others can
                    read the entire thread of messages.
                    Microsoft Access Links, Hints, Tips & Accounting Systems at

                    Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

                    Comment

                    • Tony Toews [MVP]

                      #11
                      Re: ZIP code module without DLL dependencies???

                      "Stuart McCall" <smccall@myunre albox.comwrote:


                      BTW that might not even work on my system. I did the following to disable the
                      Windows zipping and am using (a legally purchased) Winzip.

                      Irritating searching within zip files
                      regsvr32 /u zipfldr.dll

                      Tony
                      --
                      Tony Toews, Microsoft Access MVP
                      Please respond only in the newsgroups so that others can
                      read the entire thread of messages.
                      Microsoft Access Links, Hints, Tips & Accounting Systems at

                      Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

                      Comment

                      • Tony Toews [MVP]

                        #12
                        Re: ZIP code module without DLL dependencies???

                        The Frog <Mr.Frog.to.you @googlemail.com wrote:
                        >My goodness, we seem to have stirred up a lot of interest here.
                        <smile Sure, we were getting bored.
                        >With regards to using external dll's such as the infofzip ones, has
                        >anyone got an opinion to offer about their use? I was thinking that I
                        >would make a hidden table and store the dll as a blob, pop the dll
                        >into a temporary location when needed, then destroy it again at the
                        >end of the process. Has anyone done this before or have any other
                        >recommendation s? (Installing stuff is actually quite hard in this
                        >corporate environment, so minimising dependencies is crucial -
                        >effectively I need to be able to ship just an MDB / MDE file and let
                        >it do its job without concern for what is / isnt on the system in
                        >question).
                        Hmm, yes, that's possible I do beleive. Check Stephen Lebans website. Hmm, here's
                        one but it doesn't explicitly state dlls. http://www.lebans.com/oletodisk.htm That
                        said it does mention PDF files and such so it's quite possible. Worth spending a
                        half hour playing with it.

                        That's something I'm not too worried about as I don't mind packing up a few extra
                        DLLs for use. But I can see where you are coming from when dealing with IT Nazi
                        admins.

                        Tony


                        --
                        Tony Toews, Microsoft Access MVP
                        Please respond only in the newsgroups so that others can
                        read the entire thread of messages.
                        Microsoft Access Links, Hints, Tips & Accounting Systems at

                        Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

                        Comment

                        • The Frog

                          #13
                          Re: ZIP code module without DLL dependencies???

                          Hi Tony,

                          The admins here largely are the root cause of my programming problems.
                          They make unpredictable changes to the OS's on every machine, dont
                          tell anyone anything, and refuse to take any accountability for their
                          actions - in short they dont manage all that well and arent made to.

                          The result is that I have lost many months worth of work due to their
                          actions (I think something like ~60k lines of code this year so far)
                          because I cannot guarantee that the application will actually be able
                          to run on any given day. Some days they work fine and others they
                          simply wont at all. No way to predict it unfortunately.

                          Because of this I have set about collecting / creating modules for MS
                          Access (97) that remove the dependencies from the system itself and
                          therefore minimise the risk of the application not running. I still
                          have to keep a copy of MDAC installers on standby, but thats about it.
                          Right now I am grappling with ZIP so that I can get some output into a
                          small enough filesize to email to a large group. The alternative would
                          be to use online drop-boxes such as rapidshare - but as I see it these
                          represent a risk that potentially sensitive data can end up easily in
                          the wrong hands (and besides, it probably breaches the rules I have to
                          stick to).

                          I will have a play with the DLL option and storing it in the app
                          itself, and dragging it out when necessary. I will keep you posted
                          with the progress. Probably wont have the time till next week though
                          to post any code on this one.

                          Cheers and thanks for your help

                          The Frog

                          Comment

                          • Stuart McCall

                            #14
                            Re: ZIP code module without DLL dependencies???

                            "The Frog" <Mr.Frog.to.you @googlemail.com wrote in message
                            news:0c3274c2-8a2a-4c33-a719-bd9551ec9a35@g2 1g2000hsh.googl egroups.com...
                            Hi Tony,
                            <SNIP>
                            I will have a play with the DLL option and storing it in the app
                            itself, and dragging it out when necessary. I will keep you posted
                            with the progress. Probably wont have the time till next week though
                            to post any code on this one.
                            >
                            Cheers and thanks for your help
                            >
                            The Frog
                            You can try this module if you like. I've been using it successfully for
                            years, to "create" DLL's, icons, pictures and gen. purpose binary data. The
                            two main routines are FileToBinaryDat a and BinaryDataToFil e. The module as
                            it stands is intended to live in a library mdb. If you wish to use it in a
                            FE, simply change all CodeDB references to CurrentDb.

                            It requires a table tblBinaryData, with the structure:

                            Item Text 50
                            Value OLE Object

                            Item is the primary key.

                            ''' CODE START '''
                            Option Compare Database
                            '
                            Private Const TPL_SELECT = "Select Value From tblBinaryData Where Item='?'"

                            Public Function GetBinaryData(B yVal Item$) As String
                            'Returns a binary item from tblBinaryData as a string

                            On Error GoTo GetBinaryData_E rr
                            '
                            With CodeDb.OpenReco rdset(Replace(T PL_SELECT, "?", Item),
                            dbOpenSnapshot)
                            GetBinaryData = !Value
                            .Close
                            End With

                            GetBinaryData_E xit:
                            Exit Function

                            GetBinaryData_E rr:
                            Resume GetBinaryData_E xit

                            End Function

                            Public Function PutBinaryData(B yVal Item$, ByVal Value$) As Boolean
                            'Stores a binary item in tblBinaryData
                            'Returns True for success

                            On Error GoTo PutBinaryData_E rr
                            '
                            With CodeDb.OpenReco rdset("tblBinar yData", dbOpenDynaset)
                            .FindFirst "Item=" & Quoted(Item)
                            If .NoMatch Then
                            .AddNew
                            !Item = Item
                            Else
                            .Edit
                            End If
                            !Value = Value
                            .Update
                            .Close
                            End With
                            '
                            PutBinaryData = True

                            PutBinaryData_E xit:
                            Exit Function

                            PutBinaryData_E rr:
                            Resume PutBinaryData_E xit

                            End Function

                            Public Function DelBinaryData(B yVal Item$) As Boolean
                            'Deletes a binary item from tblBinaryData
                            'Returns True for success

                            On Error GoTo DelBinaryData_E rr
                            '
                            With CodeDb.OpenReco rdset(Replace(T PL_SELECT, "?", Item), dbOpenDynaset)
                            If .BOF Then Exit Function
                            .Delete
                            .Close
                            End With
                            '
                            DelBinaryData = True

                            DelBinaryData_E xit:
                            Exit Function

                            DelBinaryData_E rr:
                            Resume DelBinaryData_E xit

                            End Function

                            Public Function FileToBinaryDat a(ByVal File$, ByVal Item$) As Boolean
                            'Retrieves a binary item from a file and stores it in tblBinaryData
                            'Returns True for success

                            On Error GoTo FileToBinaryDat a_Err
                            '
                            b$ = BinFileToString (File)
                            If b = "" Then Exit Function
                            FileToBinaryDat a = PutBinaryData(I tem, b)

                            FileToBinaryDat a_Exit:
                            Exit Function

                            FileToBinaryDat a_Err:
                            Resume FileToBinaryDat a_Exit

                            End Function

                            Public Function BinaryDataToFil e(ByVal File$, ByVal Item$) As Boolean
                            'Retrieves a binary item from tblBinaryData and creates a file from it
                            'Returns True for success

                            On Error GoTo BinaryDataToFil e_Err
                            '
                            b$ = GetBinaryData(I tem)
                            If b = "" Then Exit Function
                            StringToBinFile b, File
                            '
                            BinaryDataToFil e = True

                            BinaryDataToFil e_Exit:
                            Exit Function

                            BinaryDataToFil e_Err:
                            Resume BinaryDataToFil e_Exit

                            End Function

                            Public Function BinFileToString (ByVal File) As String
                            'Returns a binary item retrieved from a file

                            On Error GoTo BinFileToString _Err
                            '
                            f% = FreeFile
                            Open File For Binary Access Read Lock Write As f%
                            b$ = Space$(LOF(f))
                            Get #f%, , b
                            Close f
                            '
                            BinFileToString = b

                            BinFileToString _Exit:
                            Exit Function

                            BinFileToString _Err:
                            MsgBox Err.Description , vbCritical, "modBinaryData. BinFileToString "
                            Resume BinFileToString _Exit

                            End Function

                            Public Function StringToBinFile (ByVal bin$, ByVal File$) As Boolean
                            'Creates a file from the passed string
                            'Returns True for success

                            On Error GoTo StringToBinFile _Err
                            '
                            If Dir(File) <"" Then Kill File
                            f% = FreeFile
                            Open File For Binary Access Write Lock Read As f
                            Put #f, , bin
                            Close f
                            '
                            StringToBinFile = True

                            StringToBinFile _Exit:
                            Exit Function

                            StringToBinFile _Err:
                            MsgBox Err.Description , vbCritical, "modBinaryData. StringToBinFile "
                            Resume StringToBinFile _Exit

                            End Function
                            ''' CODE END '''



                            Comment

                            • Stuart McCall

                              #15
                              Re: ZIP code module without DLL dependencies???

                              "The Frog" <Mr.Frog.to.you @googlemail.com wrote in message
                              news:49cdee52-13c2-4450-b5bd-a8729f4dc9f8@j2 0g2000hsi.googl egroups.com...
                              Hi Everyone,
                              <SNIP>
                              Thankyou all for the valuable input on this too. The scripting stuff
                              is actually quite intriguing. I would be interested to see the single
                              file version if anyone has an idea on that one.
                              Take a look here:



                              Examples for just about everything.



                              Comment

                              Working...