Results 1 to 15 of 15
  1. #1
    New Lounger
    Join Date
    Nov 2001
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Loading documents without templates (Word 2000 (SP2))

    I am trying to load a document through documents.open into a pristine word environment (winword.exe was started with the /a switch). Unfortunately, the document has templates associated with it that exist on the system, so Word proceeds to load all the templates and associated references the minute the document is opened. How can I prevent this from happening?

    Thanks
    Vick

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    ALL documents have an assigned attached template.
    You open the document and the template attached is used. No way to prevent that IF Word can find the template on the system.

    Remove/rename the templates and the document should get opened as if it had been attached to the Normal template.

  3. #3
    Star Lounger
    Join Date
    Nov 2001
    Location
    Illinois, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    You can change the attached template as soon as the document opens, do whatever, then restore the original attached templated before closing. Probably the normal.dot is the one with the least references,etc. so maybe temporarily setting the template to normal would do the trick for you:
    strOrigTemplate = ActiveDocument.AttachedTemplate.Fullname
    ActiveDocument.AttachedTemplate ="" 'setting it to an empty string actually attaches normal.dot
    .... do whatever needs doing
    ActiveDocument.AttachedTemplate = strOrigTemplate 'restore the original template

  4. #4
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    1. On a document by document basis, hold down the shift key when you are opening a document
    2. To apply to all documents, set Tools, Macro, Security, High
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  5. #5
    New Lounger
    Join Date
    Nov 2001
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    Thank you all for the suggestions.

    Good suggestion, but unfortunately, it is not possible to rename the existing templates that already exist on the system as they may be in use.

    Opening the document though Word does not load the templates initially, so instead of using the Documents.Open method I used the dialogs object using the FileOpen dialog to open the file. This method did not load the templates initially. The minute I gained access to the instance of the document object through ActiveDocument, Word proceeded to load the templates.

    Opening Word with the /a switch automatically sets the macro security to high.

    Vick

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

    Re: Loading documents without templates (Word 2000 (SP2))

    Vick,

    Just a couple of thoughts:

    Dottie's suggestion seems quite good and it's possible you're misinterpreting it: the method she's suggesting doesn't rename any existing templates (agreed you'd never want to do that). All it does is capture the full name of the active document's attached template in a variable and goes from there - the template itself never gets renamed.

    It's true that even with this method, initially the original attached template will load when the document is opened. But once you attached Normal.dot in its stead, the attached template is closed so the references contained in it should no longer affect that Word session (I think!).

    Also, could you clarify the second paragraph - are you saying that files opened via the FileOpen dialog open up without their attached templates?

    Gary

  7. #7
    New Lounger
    Join Date
    Nov 2001
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    Here is the sequence of events that happens when handling the document manually through the Word interface.
    1-Open the document from file/open, no referenced templates load.

    Here is the sequence of events when handling the document programmatically noting that there are two ways to open a document. One, through the Open method of the Documents collection and the other by automating the native Word dialog boxes through the Dialogs collection.

    1-If I use this line of code set oDoc=Documents.Open(xxx), Word loads the document and every referenced template

    1-If I use the With Dialogs(wdDialogFileOpen)
    .Name=xxx
    .Execute
    End With
    Word loads the document, but not the referenced templates
    2-Then using this line of code ActiveDocument.AttachedTemplate=xxx, Word loads all the referenced templates before executing the statement.

    The conclusion is that the minute a reference to a document is gained programmatically, Word's default behavior is to load all templates associated with this document.

    In order to bypass this behavior, I am trying to automate the opening of the document and changing its template BEFORE gaining programmatic access to the document's reference. I can open the document through the Dialogs method outlined above and now I am trying to find a way to change the template without gaining access to the document reference (and by not using sendkeys). Unfortunately there seems that there is no wdDialogAddIns. I found a wdDialogToolsTemplates, but I am not sure what it is for as it did not seem to work

    Let me know if this explanation is clearer.

    Thanks

    Vick

  8. #8
    Star Lounger
    Join Date
    Sep 2001
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    Sometimes it is easier to go the "long" way.
    Perhaps you might attach an empty template and then simply close all unnecessary templates after Word has loaded them automatically?

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

    Re: Loading documents without templates (Word 2000 (SP2))

    Hi Vick,

    The explanation is logical, but I was still not understanding why you were doing all this, starting with the second line: "Open the document from file/open, no referenced templates load."

    I think what everyone was understanding you to be speaking about was the document's attached template loading (which can't be avoided), while what you were speaking about was templates that were referenced in the individual template, loading.

    I'm familiar with setting a reference in a template, to one or more global templates. One reason for doing this is that it allows code in the individual template to call functions that are in the global template, including sending/returning parameters in the form of global variables.

    In that scenario though, the referenced templates are usually global templates that are located in the Startup directory; since they are always loaded there's never an issue with the reference in the individual template forcing the referenced template to load - it already is loaded.

    If I'm understanding correctly what you've got set up (stop me if I've got this wrong...):
    The document that's opening is based on a custom template.
    When you developed this custom template, you set a reference in this template, to one or more other templates (this is done via Tools>References in the VBE, and putting a checkmark next to a template project listed there).

    Now, the only template projects that are ever going to be visible in Tools > References are those that are currently open. This would include any global templates that are open by virtue of being in the Startup directory or by having been loaded as add-ins, as well as Normal.dot and any other custom templates that may be open at that moment.

    Since you're discussing a problem with referenced templates being forced to load when you open a document, it's clear that the templates you set references to are not in the Startup directory (since they would already be loaded before the document opens).
    So I guess you're setting a reference to a global template that has been loaded as an add-in, and was loaded when you set the reference while developing the individual template, but which under normal circumstances isn't loaded.

    - have I got this right?

    - if so, do you really need to set up the references this way? Setting a reference to an add-in that normally isn't loaded seems like a lot of trouble. It might be possible (and interesting) to go forward trying to sleuth some workaround to the problem of the add-in being force-loaded (such as letting the document open and the add-in force-load, then immediately cycling through the add-ins collection to find the add-in that was force-loaded and unload it), but isn't there any alternative way to deploy things that would make life simpler?

    Gary

  10. #10
    New Lounger
    Join Date
    Nov 2001
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    Everything you mentioned is correct. The only missing point is that I am trying to do all this in a Second instance of Word that I have started using the /a command line parameter (By the way this alone is complicated programmatically as Word insists on displaying the User Information dialog box when launched with the /a switch, I am not sure that I have this completely down yet). I need a Word environment free of any loaded templated and Addins without impacting the current work of the user. So naturally, I don't want to end it in the user's environment by opening documents that load back the user's templates into the new Word process. So, upon opening a document, I want to get rid of the referenced template programmatically, without gaining access to the document object.

    Vick

    VIck

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

    Re: Loading documents without templates (Word 2000 (SP2))

    Vick,

    Anything useful in <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=30593&page=&v iew=&sb=&o=&vc=1#Post30593>this post</A> and related thread?

    Gary

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    Lemme clarify.

    Application.RambleMode = True

    When you Open a document, no matter by which method, the Attached template is also referenced.
    If the attached template is specified by a path that does not exist on the system, then Word searches thru ceratain directories to find an identically named template. If none is found, then the document is opened as if it were attached to the Normal template.

    THere is no way to open a document without some Attached template being referenced.

    IN addition, there is ON:Y 1 template attached to a document. Any other referenced templates are global templates, e.g., those in Word's StartUp directory, those loaded by particular add-ins and those loaded by, say, the AutoEXec and AutoOPen macros.

    I've never checked whether it is possible (unless done with a macro) to not load the templates in the StartUp directory or those loaded by an add-in.

    If you start Word so that AutoExec and AutoOpen are not executed, then that might make a difference.

    Application.RambleMode = False

  13. #13
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    You can unload all Global templates and Add-ins and you can Attach a "clean" Normal.dot, but there's always gonna be a template attached to the document. YOu cannot avoid this.

  14. #14
    New Lounger
    Join Date
    Nov 2001
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    Thanks all for you help.

    Sorry about the delay, but I had a new baby girl in the mean time. I will try to see if the references have already loaded at the time of opening the document. My other choice to try is to revert to the WordBasic object and see if I can delete the template reference by accessing the template dialog box without having to gain access to the document object through Word 2000. I am hopeful that the WordBasic object will yield the answer. I will let you know

    Vick

  15. #15
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading documents without templates (Word 2000 (SP2))

    THere's no way to have a document open without having an attached template.

Posting Permissions

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