• File size grows when compiling (W2K/O2K pro UK,)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » File size grows when compiling (W2K/O2K pro UK,)

    Author
    Topic
    #388867

    Just wondering…

    Can anyone explain to me, why my Word .dot files grows when compiled ?

    I had a file I’ve been working on for some while, after final development works were done it was approx. 2.4mb.
    Then I exported all modules and made a new .dot to which they were then imported. (File size fell to 744K.
    Then I compiled it and was ready to release test it. (but was somewhat stunned to see that after compiling it had grown to 1.3mb)

    Any good explanations on this….( normal “growth” I expect must be the result of some kind of “append” operation going on in the “Word engine”)

    ;o)) Henrik

    PS: No Office version up- or downgrades are involved here, it’s all O2K.

    Viewing 0 reply threads
    Author
    Replies
    • #684506

      It is because compiling adds “machine like” code to the file, which VBA uses to do the execution (or so I gather ).

      BTW: are you aware there is a Word code cleaner utility that simplifies the job of exporting, deleting/importing? Find it here:

      http://www.mvps.org/word/FAQs/MacrosVBA/TemplateBloat.htm%5B/url%5D

      • #684519

        Thanks,

        Yes I’m aware of the code cleaner and has used it in various situations.
        However, it is not a 100% efficient. we did a test using both methods and there was some difference – favouring the manual way.
        But for general purposes I do agree – it’s sufficiently efficient.

        Thanks again,
        ;o) Henrik

        • #684548

          The reason it is not entirely efficient is that VBA does a terrible job cleaning after itself.

          Try this:

          Dim sTest as String

          Now type:

          stest=”Hi”

          You’ll see it change to:

          sTest=”Hi”

          Now remove the dim statement and redo the typing. VBA still remembers the DIM and capitalises!

          Another point to be aware of, is that code inside Object modules (Thisdocument e.g.) cannot be cleaned. Therefore copying all your code to a fresh doc will be different from using code cleaner. It is for this reason I tend to put as little code as I possibly can into those modules.

          • #684882

            Interesting….

            Wasn’t aware of the Object module issue, but has never put much code in there myself either always used “clean” modules.
            (found unconsciously that they provided a better structure and fewer problems – now I know what can be one of the reasons, thanks)

            If I read your previous mail correctly, then the obj. mod. issue can also be the reason why new projects get corrupted ??

            ;o)) Henrik

    Viewing 0 reply threads
    Reply To: File size grows when compiling (W2K/O2K pro UK,)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: