Results 1 to 13 of 13
  1. #1
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Moving between Documents (Office 2003)

    Can anyone help, please!?! I have a global toolbar which has a Styles button. When I create a document based on one of my templates, the Styles button populates with all the relevant styles specific to that template. What I need to happen is for the Styles button to update when I move to other documents, eg if I have a document that is not part of the template set I don't want styles to show.

    I have a "Document Change" function held in the global template (where the toolbar is creating) but it doesn't appear to run when I move between documents. Does anyone know how to identify moving between documents? I had presumed it was Document Change.

    Many thanks
    Jack

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

    Re: Moving between Documents (Office 2003)

    DocumentChange is the event to monitor switching between documents. I assume that you have set up a class module with a WithEvents variable, etc., but are you sure that it it initialized properly, i.e. you create an instance of the class, and set the variable? Please be aware that a Document_Open macro does not run in a global template (since it is not opened as a document); you must use a macro named AutoExec in a standard module to initialize things in a global template.

  3. #3
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Moving between Documents (Office 2003)

    I have set up the DocumentChange event which runs perfectly fine if I open documents through Windows Explorer and also through Word. I have noticed though that it appears to be intermittent and doesn't always run when moving around documents. I did use the information provided by the Microsoft website to set up the DocumentChange event so I am presuming that it is set up correctly.

    Is DocumentChange the only option?

    Thanks
    Jack

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

    Re: Moving between Documents (Office 2003)

    I don't know of another way to monitor switching between documents. I have never noticed that the event doesn't work. But if an error occurs, all variables are cleared, so the event handler wouldn't work any more. Perhaps that is what causes it "to be intermittent". You would have to re-run the initialization routine to start it again.

  5. #5
    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: Moving between Documents (Office 2003)

    Although it creates a bit of delay for the user, you could change your toolbar code so that the list updates (or refuses to work, as the case may be) when the user accesses the drop-down. To minimize the number of updates, you could stash the name of the relevant document/template in the control's .Tag property and, if it already matches, you don't have to do the update. I have no idea whether this would yield a good user experience, but it is a possible workaround.

  6. #6
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Moving between Documents (Office 2003)

    I did look into the "On Action" event but found that it would not run the On Action command when the button was set as a CommandBarPopup. Does the CommandBarPopup need to be treated differently than a CommandBarButton?

    Thanks
    Jack

  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: Moving between Documents (Office 2003)

    <P ID="edit" class=small>(Edited by jscher2000 on 27-Sep-04 18:29. )</P>Sorry, I was thinking of a drop-down control. A pop-up is a sub-menu, right? So you would need to attach the action to the individual items on the sub-menu. Actually, that seems quite inefficient. Obviously I don't understand how your toolbar works. <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

    Added: Here's a sample document containing a custom toolbar. When you drop the toolbar, the OnAction runs and adds a new item to the list. Every time. So I'm not sure why yours isn't working. I tested in Word 2002.

  8. #8
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Moving between Documents (Office 2003)

    My understanding is that the CommandBarPopup allows CommandBarButtons to be created beneath it. In this case the CommandBarPopup is called "Styles" and the CommandBarButtons, which appear below "Styles", is a list of the styles specific to the document. The OnAction command works well if I select one of the CommandBarButtons under the "Styles" button but does not seem to work if I use the OnAction command on the CommandBarPopup, eventhough the option is available.

    The reason why the "OnAction" may not work could be due to the fact that if you run your cursor over the CommandBarPopup the list of styles will appear below therefore the OnAction does not have to run as the user can access the list without physically clicking on the Styles button.

    When originally setting up the Toolbar I did post a question, on Woody's Lounge, on how to set up a list and was recommended to create a CommandBarPopup and CommandBarButtons beneath - hence I have set the Toolbar as recommended. The only problem is the functionality is restrictive !!

    It's all very confusing !!!!
    Regards
    Jack

  9. #9
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Moving between Documents (Office 2003)

    Jack

    I can understand that you would like your styles list to reside on the global toolbar but this is a very complex way to arrange it.

    The simple solution is to make store the styles list relevant to the attached template in the attached template. That way when you shift from document to document, you always see the styles list relevant to the attached template and no code is required at all. If the toolbar that holds this styles list always appeared in the same place irrespective of which one of your templates was attached then the functionality would remain the same as your global toolbar method without the pain.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  10. #10
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Moving between Documents (Office 2003)

    Thanks Andrew ... just a quick question. As recommended by yourself, I created a styles toolbar within each template, when the document (Letter) runs a style toolbar appears that is specific to the Letter. If I then create another document (in this case Fax) two toolbars appear on the Fax created document - styles toolbar specific to the Letter and a styles toolbar specific to the Fax.

    This problem does not occur if the document is closed as I can remove the toolbar but if a user keeps more than one document open the repeated toolbar happens.

    Have I set the toolbar up correctly?

    Many thanks for your help
    Jack

  11. #11
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Moving between Documents (Office 2003)

    Jack

    I don't think you have the toolbars setup correctly. If a toolbar is contained in the attached template of a file then it is available on-screen only when a file with that attached template is activated. If you activate the other file then the first toolbar (from the template attached to file 1) should disappear and the toolbar from the template attached to file 2 should appear. I am not on a Word 2003 machine at the moment but I can't imagine this behaviour being different in Word 2003. Do the multiple toolbars both disappear if you detach the attached template?

    Perhaps you have loaded one of these templates as a global template. That would keep the toolbar available whether the doc was activated or not. If this is not the case then perhaps one of the toolbars is stored in Normal.dot.

    Can you check in Tools > Templates and Add-ins and make sure there is no global templates active. Now try the two files.

    If this doesn't work, try the Tools > Template and Add-ins and click the Organizer button and check which toolbars are loaded in which templates.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  12. #12
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Moving between Documents (Office 2003)

    Andrew,
    You're absolutely right about the toolbar behaviour. No difference in Word 2003, which I'm using now.

  13. #13
    Star Lounger
    Join Date
    Jun 2004
    Location
    Gtr London, England
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Moving between Documents (Office 2003)

    Morning Andrew ... Problem has now been solved (fingers crossed). I have a global template (which creates a toolbar) that all other templates call, my preference was to run the "Styles" through this toolbar (as mentioned). I have managed to populate the styles for each template, include them under the Styles button as a separate button (eg Letter), then populate all the letter styles under the Letter button. When a document created, using the letter template closes, the button is removed.

    It's all working fantastically well.

    Thanks for your help
    Jack

Posting Permissions

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