Results 1 to 11 of 11
  1. #1
    Lounger
    Join Date
    Aug 2003
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change document focus (word 2000 )

    I have 2 documents, one is a template and the other is a document. i want to change the focus to the document while the template is updating the document. Hwo do i do that?

    Thanks...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change document focus (word 2000 )

    Do you have the template open in a window while doing this? Why?

  3. #3
    Lounger
    Join Date
    Aug 2003
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change document focus (word 2000 )

    the template has the macros in it. and the document has the bookmarks. Am i going about this the wrong way??

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change document focus (word 2000 )

    Usually, a template works invisibly in the background, it doesn't need to be visible to work. The Normal.dot template for instance is always loaded in Word, but it isn't visible unless you open it explicitly. The same holds for global templates (templates in the startup folder).

    If you create a document from a template (File | New... interactively, or Documents.Add Template:="templatename" in VBA, the template is loaded invisibly; the macros are available but you don't see the template itself in Word.

  5. #5
    Lounger
    Join Date
    Aug 2003
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change document focus (word 2000 )

    Ok, so if i have a test.dot(which has the macros in it, it also has userforms which pop up when it is invoked), how can i make it work invisibly on a test.doc file? maybe i am doing this the wrong way ? Sorry if I am frustrating you

    thanks ...

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change document focus (word 2000 )

    There are two ways you can do this:

    1) Store the template in the startup folder for Word. To find out which folder this is, select Tools | Options... in Word, activate the File Locations tab, and inspect the setting for Startup. If you can't see the complete path, select Startup and click Edit...
    If you put your template in the startup folder, it will be loaded automatically as an invisible add-in when you start Word. You will see it listed in Tools | Templates and Add-ins. Macros in this template will be available in all documents.

    2) Store the template in the user templates folder. If you Save As a template, this will be the default location. If you want to find out which folder this is, select Tools | Options... in Word, activate the File Locations tab, and inspect the setting for User Templates. If you can't see the complete path, select Startup and click Edit...
    If you put your template in the user templates folder, it will be available if you select File | New... When you create a document based on the template, the AutoNew macro (in a standard module) or the Document_New macro (in ThisDocument) will be executed automatically. The macros in the template will only be available when a document based on the template is active.

    You don't have to apologize for asking questions. <img src=/S/smile.gif border=0 alt=smile width=15 height=15> We all have had to learn, and we are all still learning every day. The Lounge is there to help everyone, from absolute beginners to intermediate users to experienced professionals.

  7. #7
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change document focus (word 2000 )

    Hi Hans,

    An additional question/comment.
    If I've understood it correctly templates loaded as global templates (potentially added through code as they become needed) also make their macros available, eventhough they are not the "attached template" - isn't this correct ?

    I'm using this method to keep down the complexity and size of my templates.
    Keeping styles and minor autotext formatting issues in "the master" and all additional code in templates that load/unload as they become needed...
    - if the functions become general enough they can subsequently be turned into .dll's

    Henrik
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change document focus (word 2000 )

    Yes, macros in global templates are available in every document, the document doesn't have to be based on the global template. In fact, you never base a document on a global template.

  9. #9
    Lounger
    Join Date
    Aug 2003
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change document focus (word 2000 )

    Hans,

    Thanks for the 2 solutions. But unfortunately both these solutions wont work in my case, since i DONT want to automatically run the template for ALL Word Documents. Also, this template will be used by a variety of users on the WAN worldwide and i cant ask the user to keep track of the directories etc.. All i want to be able to do is send the user the .dot file(template) and the .doc file ( the bookmarks etc which will in turn be saved as the final docuemnt) and they will invoke it from an application that is built to call the .dot file.

    So, let me know what i can do to acheive that...

    Thanks again.. You are a great help <img src=/S/clever.gif border=0 alt=clever width=15 height=15>

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change document focus (word 2000 )

    Since you send the document and the template to the user, you know the name of the document. Say it's named MyDocument.doc. You can activate it using

    Documents("MyDocument.doc").Activate

  11. #11
    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: Change document focus (word 2000 )

    If you create the document using Documents.Add, you can create an object reference to it:

    dim docTemplate as document, docBlank as document
    set docTemplate = activedocument ' reference to myself, as the template with the code in it
    set docBlank = Documents.Add
    ' to switch to docBlank
    docBlank.Activate
    ' to switch to the template
    docTemplate.Activate

    Note: I just typed this in without testing, so beware of typos.

Posting Permissions

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