Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    New Lounger
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    toolbar positioning (2002 SP3)

    I created a template with quite a few AutoText entries and added them to three toolbars. The entries all work correctly, but when I open the template, the third toolbar moves to the end of the second toolbar and I have to manually move it to the next row. That's OK for my use, but others need to use the template, and I don't want to have to explain how to do this every time someone opens the template. Suggestions on how to make the toolbars behave?

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

    Re: toolbar positioning (2002 SP3)

    Welcome to Woody's Lounge!

    You could put the following macro in a standard module in the template:

    Public Sub PositionToolbars()
    Application.ScreenUpdating = False
    With CommandBars("Toolbar2")
    .RowIndex = CommandBars("Toolbar1").RowIndex + 1
    .Left = 0
    End With
    With CommandBars("Toolbar3")
    .RowIndex = CommandBars("Toolbar2").RowIndex + 1
    .Left = 0
    End With
    Application.ScreenUpdating = True
    End Sub

    Replace Toolbar1, Toolbar2 and Toolbar3 with the names of your custom toolbars.

    Create the following event procedures in the ThisDocument module of the template:

    Private Sub Document_New()
    Call PositionToolbars
    End Sub

    Private Sub Document_Open()
    Call PositionToolbars
    End Sub

    This will call the PositionToolbars macro when a new document based on the template is created, and when an existing document based on the template is opened.

  3. #3
    New Lounger
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: toolbar positioning (2002 SP3)

    Thanks. The macro works perfectly if called manually from within a document based on the template, but it doesn't run automatically, even though I added the event procedures into the ThisDocument of the template. When I check the ThisDocument in the new document, those procedures don't appear (which I assume accounts for the macro not running).

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

    Re: toolbar positioning (2002 SP3)

    The Document_New and Document_Open procedures should *not* appear in the ThisDocument module of a document based on the template. A document always has access to the code in the template it's based on.

    If you click anywhere in the Document_New procedure in the ThisDocument module of the template, do the dropdown boxes at the top of the module window look like those in the screenshot below (and similar for the Document_Open procedure)?
    Attached Images Attached Images
    • File Type: png x.png (2.3 KB, 0 views)

  5. #5
    New Lounger
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: toolbar positioning (2002 SP3)

    Yes, except for the Option Explicit statement.
    Attached Images Attached Images

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

    Re: toolbar positioning (2002 SP3)

    Make sure that macro security is not set to High in Tools | Macro | Security; Medium is the best setting. Also make sure that "Trust all installed add-ins and templates" is ticked in the Trusted Sources tab of the same dialog.

    If that doesn't help, could you create a copy of the template, remove most or all text from the copy, zip it and attach the zip file to a post?

  7. #7
    New Lounger
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: toolbar positioning (2002 SP3)

    Both settings match your recommendations. A copy of the template is attached.
    Attached Files Attached Files

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

    Re: toolbar positioning (2002 SP3)

    There are no custom toolbars in your template, nor any code. I suspect that you stored them in your Normal.dot template instead of in this template...

  9. #9
    New Lounger
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: toolbar positioning (2002 SP3)

    Sorry, for some reason they didn't carry over to the copy of the template that I sent before. I've now saved them in this version of the template copy.
    Attached Files Attached Files

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

    Re: toolbar positioning (2002 SP3)

    Thanks. This time, the template contains the custom toolbars and the PositionToolbars macro. However, there is still no code in the ThisDocument module.

  11. #11
    New Lounger
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: toolbar positioning (2002 SP3)

    OK, I obviously need to check more closely before I send files. I believe this one has all the components!
    Attached Files Attached Files

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

    Re: toolbar positioning (2002 SP3)

    Yep, it does, and when I create a new document based on the template, and when I reopen such a document after saving and closing it, the code runs automatically. I checked this by adding a line

    Beep

    to the PositionToolbars macro. I get a beep in both situations mentioned above. Have you tried working with this copy of the template?

  13. #13
    New Lounger
    Join Date
    Dec 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: toolbar positioning (2002 SP3)

    Well, I added Beep at the end of the PositionToolbars macro and opened the template (and a document based on the template). In both cases, I heard the Beep, but the toolbars never reset.

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

    Re: toolbar positioning (2002 SP3)

    Sorry, I cannot explain that. I moved the toolbars deliberately to one row. If I disable macros when opening the template or a document based on it, they remain on one row. If I enable macros, the toolbars are moved to three different rows. So the event procedures do work as intended.

  15. #15
    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: toolbar positioning (2002 SP3)

    Sometimes other add-ins and global templates can interfere with toolbar changes. You could selectively enable and disable any in your environment and see whether that makes any difference.

Page 1 of 2 12 LastLast

Posting Permissions

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