Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Location
    Scott AFB, IL, USA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Size of template (DOT) file (Word 2000/SR-1)

    My organization uses VBA code running under Microsoft Word to do a lot of automated processing of documents. As we have added more and more features the size of the file that contains the macro code has grown as well (it is now over 600k). A few weeks ago I added some functionality to the code and released it to the users. Ever since, some users have been (intermittently) getting an error that says "Run-time error'-2147417848 (80010108)'; Automation Error The object invoked has disconnected from it clients."

    The strange thing is, this error occurs when the users are using a part of the code that was not changed in the last release. I can temporarily clear the problem by rebuilding the template file (thus removing any custom macros or autotext that they may have added) or deleting the 'HKEY_CURRENT_USERSoftwareMicrosoftOffice9.0WordDa ta' key from the registry (this also has the effect of removing some of the customization the user might have made). Because of this, I think the problem may be related to the size of the template.

    My assumption was that the size was too large (over 600k) so, using VB6, I created a DLL and started shifting forms and common functions over to the DLL. Then I started removing forms and functions from my VBA code in the template file. Now when I need to use the function or form I call it from the DLL. By doing this I was able to bring the size down from 616k to about 513k. I pushed the new version out to my users on July 10th and so far the problems I was having have disappeared.

    Has anyone else had this type of problem? Is there an easier or better way to fix it?

    Thanks for the help.

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Size of template (DOT) file (Word 2000/SR-1)

    Hi Tom:
    I'm not a VBA expert, but I thought I'd mention to you that there is a free add-in by Prime Consulting called Code Cleaner. This will help keep the template size down. You can find it here.

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Size of template (DOT) file (Word 2000/SR-1)

    <P ID="edit" class=small>Edited by Gary Frieder on 31-Jul-02 02:22.</P>Tom,

    [Edited to add link to MS KB article - Gary]

    Sorry I don't know what is causing that automation error message, but one thing for certain is that a template filesize of 600kb will not cause that problem in and of itself - at our firm we have many 'local' templates which are this size, and our global template tops out at a bit bigger than 1Mb.

    It certainly seems like this error is related to some specific code, or perhaps some other object such as a control on a userform that may be causing problems. The fact that the problem appears to go away when you move form(s) into the .dll seems to point to the version of the form in the template (or some control on the form) being faulty in some way.) Also, does your template contain any references to other applications?

    Would you be able to post the part of the code that is running when the error occurs?

    BTW in my view the added hassles of maintaining (and deploying) some of your code and userforms in a dll, as opposed to keeping them in a (global) template, far outweighs any possible benefit of saving a mere 100kb in template size - there may be some valid reasons for saving code as a .dll (though I'm skeptical), but certainly not for the purpose you're describing. (Although no denying that you've now got it working....<g>)

    Gary

    PS Wonder if MS KB Article Q319832 may be relevant to your situation? This looks like a fascinating article (will need to read it soon as I have time!) and is the first detailed explanation I've seen about the disadvantages of early binding! (or at least early binding without certain precautions taken)

  4. #4
    New Lounger
    Join Date
    Jul 2002
    Location
    Scott AFB, IL, USA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Size of template (DOT) file (Word 2000/SR-1)

    Gary,

    Thanks for the information. Its good to know that the size is not the problem.

    Here's some more information about our situation here: We don't put much code into the default user template file (normal.dot). We leave that for the users (some of them are savy enough to develop their own unique macros or autotext entries). We put the document processing code into a separate template file called DABBS.dot. Then we set up each machine so that DABBS.dot appears in the list of 'Global templates and add-ins'. Its the DABBS.dot file that was in the 600kb range.

    Some of the forms I converted from macro code to the DLL were quite old. In fact they were not defined as forms but were defined using 'Wordbasic' commands. Here's an example:

    WordBasic.BeginDialog 414, 236, "Microsoft Word"
    WordBasic.OKButton 57, 209, 88, 21
    WordBasic.ListBox 14, 7, 384, 194, ListBox1$(), "ListBox1"
    WordBasic.CancelButton 218, 209, 88, 21
    WordBasic.EndDialog

    These I converted to Visual Basic forms (*.frm files) and incorporated them into the DLL. Perhaps is was this conversion from WordBasic to a VB form that really fixed the problem?

    Regardless, I'm in the middle of searching out all WordBasic code and converting it to VBA code.

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Size of template (DOT) file (Word 2000/SR-1)

    Tom,

    Can't comment on the WordBasic forms as I came to Word after the intro of VBA, however converting the forms can only be a good idea.

    Having had a chance to look at the KB article mentioned in my last post, the key information there is that if you are using automation (i.e. programatically create an instance of another application and then use code to manipulate it) to run any Office app (whether from VB or from another Office app), and using early binding, all code references to objects or methods in that app must be fully qualified i.e. "objWordApp.ActiveDocument... etc".

    Using an unqualified reference can lead to hidden instances of the automated app sticking around, even if you think you've Quit it, which then leads to errors the next time you run the automation code - this article was a real eye-opener as it's the first I've learned about dangers associated with using early binding!
    In this specific regard, using late binding is safer than using early binding, as the problem with unqualified references does not occur when late binding is used - who knew? - the general wisdom is that early binding is better than late binding because (1) it runs faster, and (2) it's safer in that it's easier to avoid runtime errors since you have access to the referenced type library while in working on the code, making it easier to write the code and easier to debug it.

    Apropos of the above, are you doing any automation in your template code?

    Gary

  6. #6
    New Lounger
    Join Date
    Jul 2002
    Location
    Scott AFB, IL, USA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Size of template (DOT) file (Word 2000/SR-1)

    Gary,

    No I'm not using any automation. At least not as I understand it from the article. I do access some of the objects on the MS Word object model and use them to search, replace, copy, paste, etc. But its all done from the macro code (VBA) within Word (i.e. not creating a new instance of Word and manipulating it from code).

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Size of template (DOT) file (Word 2000/SR-1)

    I have to suggest an exception to this:

    > converting the forms can only be a good idea.

    For a legacy application that won't need any UI changes, the old-style dialogs are much, much faster to load. However, the handy Dialog Editor no longer exists, so if you need to redesign, you might as well convert over to the UserForm method.

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Size of template (DOT) file (Word 2000/SR-1)

    If that's the case, and rebuilding the forms in VB has solved the problem, then it sounds like some indeterminate oddness was going on with the old forms. Glad you've got it working now.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •