Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Toolbars and menus in document (not template) (Word 2003)

    Hi

    Have I got this right (for Word 2003)? You can have a menu that resides in the document (rather than in the template), but you can't have a toolbar that resides in the document? (If so, what a pity.)

    Thanks
    Dale

  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: Toolbars and menus in document (not template)

    Hi Dale:
    I still have Word 2000, so unless MS is going backwards, you should be able to have a toolbar in a document. If you go to "Tools/Customize.../Toolbars tab/New.../Make toolbar available to:" you should be able to choose your document name in the dropdown list.
    Hope this helps,

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Toolbars and menus in document (not template)

    Something screwy here, Phil. In Word 2003 I can only see "normal.dot" and the attached template (see screenshot).

    Can someone who has 2003 confirm they get the same?

    Thanks
    Dale
    Attached Images Attached Images

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

    Re: Toolbars and menus in document (not template)

    Hi Dale:
    Are you sure that you have a document open when you try this? And did you click on one of the arrows to see if there's a third choice? You may only have a template open. According to this article, you can save a toolbar to a document in Word 2003.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Toolbars and menus in document (not template)

    Hi Phil

    I did have a document (not a template) open, but you're right, there is a third item in the teensy weensy "Make toolbar available to" drop-down. Apart from feeling vaguely embarrassed about this (yes, I should have noticed the spin buttons), what I really want to know is the name of the drongo who designed the dialog box so I can do excruciating things to him (bet you it was one of us males), very slowly. All that landscape available, and he provides users with a two-deep drop-down box that can contain three items. And what's even more embarrassing, it looks like it's been there since Word97!!!

    1, 2, 3, 4, 5, ... ... ... 999, 1000. That's better. Ready to move forward now.

    Right. What I'm working on has to run on Word2003, but today I only have access to Word97, so I'm trying to finish it in that environment. But that's okay, because, as I now understand it, it should also work in Word97.

    Here's the scenario. I have a template that's used for creating a set of user guides. I want this toolbar to be available to users who download any of these user guides from the intranet. Although the documents are linked to the template while they're being developed, when they're published on the intranet that link will be broken (that is, they will point to normal.dot, which I have no control over).

    So, here's my solution. The template contains an AutoOpen that calls the code below. (I chose AutoOpen rather than AutoNew, because there are lots of existing documents based on this template.) The code checks whether the document contains the toolbar. If it doesn't it copies the toolbar from the template to the document. That way, when the document is eventually published on the intranet, it has its own toolbar.

    Here's my code:
    <pre>Public Sub MfsUserGuideToolbar_MakeVisible()
    Dim MyToolbar As CommandBar, MyToolbarName$
    MyToolbarName$ = "MFP user guides"
    '-----------------------------------------------------------
    'If the document contains the toolbar, make sure it's visible
    For Each MyToolbar In ActiveDocument.CommandBars
    If MyToolbar.Name = MyToolbarName$ Then
    MyToolbar.Visible = True 'XXXXXXXXXXXXXX
    Exit Sub
    End If
    Next MyToolbar
    '-----------------------------------------
    'The document doesn't contain the toolbar.
    'Copy it from the template and make it visible.
    For Each MyToolbar In ActiveDocument.AttachedTemplate.CommandBars
    If MyToolbar.Name = MyToolbarName$ Then
    Application.OrganizerCopy _
    Source:=ActiveDocument.AttachedTemplate.FullName, _
    Destination:=ActiveDocument.FullName, _
    Name:=MyToolbarName$, _
    Object:=wdOrganizerObjectCommandBars
    MyToolbar.Visible = True
    Exit Sub
    End If
    Next MyToolbar
    '-------------------------------------
    End Sub
    </pre>


    It doesn't work as I expected. The confusing thing is that, if I open a document using this template, the code reaches the point marked XXXXXXXXXXXXXX even though the document does NOT contain the toolbar. (I know if doesn't for two reasons: 1. It's never been subjected to this code before, and 2. If I remove the link to the template the toolbar disappears from the list of toolbars in Tools|Customise.)

    What am I doing wrong? (Please don't tell me I'm stupid. This is not a good time to mention it.)

    PS: Apologies for the length of this missive. I figure this is a bit complicated, so it'll save time to get all the facts on the table right from the start.

    Thanks
    Dale

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

    Re: Toolbars and menus in document (not template)

    Hi Dale:
    Sorry. I'll have to let one of the VBA experts answer this one.

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

    Re: Toolbars and menus in document (not template)

    The problem is that CommandBars is deceptive. Whatever you qualify it with (ActiveDocument.CommandBars, ActiveDocument.AttachedTemplate.CommandBars, Application.CommandBars or just CommandBars), it returns the collection of all commandbars that are available at that moment. As long as the document is attached to its template, your custom toolbar is available and hence part of the CommandBars collection.

    Why don't you just copy the toolbar to the document manually?

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Toolbars and menus in document (not template)

    Thanks, Hans

    Why don't you just copy the toolbar to the document manually?
    Partly because I'm lazy (there are thirty of these manuals). And partly because I think it's something I'll want to do again, so I was trying to create a nice little mechanism.

    Achieving this objective
    Are you saying there is no way of determining whether the document contains the toolbar?

    Dale

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

    Re: Toolbars and menus in document (not template)

    Perhaps a different approach will do what you want. The following event procedure should go into the ThisDocument module of the template. It will copy the toolbar into a new document when you create it from the template. The last line before End Sub detaches the document from the template; if you don't want that, comment out this line.

    Private Sub Document_New()
    Const MyToolbarName = "MFP user guides"
    Application.OrganizerCopy _
    Source:=ActiveDocument.AttachedTemplate.FullName, _
    Destination:=ActiveDocument.FullName, _
    Name:=MyToolbarName, _
    Object:=wdOrganizerObjectCommandBars
    CommandBars(MyToolbarName).Visible = True
    ' Optional: detach document from template immediately
    ActiveDocument.AttachedTemplate = "Normal"
    End Sub

Posting Permissions

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