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

    CommandBars: Top property (Word)

    The problem described below occurs in Word 2003 and Word 2002, I've not recently tried in Word 2000 and Word 97.
    Similar code does not have this problem in Excel 2003 or PowerPoint 2003.

    For a CommandBar, the Top property means "For docked command bars, this property returns or sets the distance from the command bar to the top of the docking area".

    Running the following code, the two command bars are created, as desired, each on a separate row at the bottom of the window.

    However, after saving and closing the template, both toolbars appear on the same row. This occurs whether or not I set the Left propert to 0.

    Anybody got an explanation?

    <pre>Option Explicit

    Private Sub CommandBarTop()
    Dim cmdbar As office.CommandBar
    Dim cmdbutton As office.CommandBarButton
    Dim tmpActive As Word.Template
    Dim intBeforeIndex As Integer
    Dim lngCommandBarBottomHeight As Long

    Set tmpActive = ActiveDocument.AttachedTemplate

    CustomizationContext = MacroContainer

    lngCommandBarBottomHeight = 0

    Set cmdbar = CommandBars.Add(Name:="First", Position:=msoBarBottom, Temporary:=False, MenuBar:=False)
    With cmdbar
    .Visible = True
    .Top = lngCommandBarBottomHeight
    .Left = 0
    lngCommandBarBottomHeight = lngCommandBarBottomHeight + .Height
    End With

    ' Create controls for First command bar here
    intBeforeIndex = 1
    Set cmdbutton = cmdbar.Controls.Add(Type:=msoControlButton, Temporary:=False, Before:=intBeforeIndex, ID:=331)
    With cmdbutton
    .Style = msoButtonIcon
    .FaceId = 106
    .TooltipText = "DocClose"
    End With

    intBeforeIndex = intBeforeIndex + 1
    Set cmdbutton = cmdbar.Controls.Add(Type:=msoControlButton, Temporary:=False, Before:=intBeforeIndex, ID:=141)
    With cmdbutton
    .Style = msoButtonIcon
    .FaceId = 46
    .TooltipText = "EditFind"
    End With


    Set cmdbar = CommandBars.Add(Name:="Second", Position:=msoBarBottom, Temporary:=False, MenuBar:=False)
    With cmdbar
    .Visible = True
    .Top = lngCommandBarBottomHeight
    .Left = 0
    lngCommandBarBottomHeight = lngCommandBarBottomHeight + .Height
    End With

    ' Create controls for Second command bar here

    intBeforeIndex = 1
    Set cmdbutton = cmdbar.Controls.Add(Type:=msoControlButton, Temporary:=False, Before:=intBeforeIndex, ID:=752)
    With cmdbutton
    .Style = msoButtonCaption
    .Caption = "FileExit"
    .TooltipText = "FileExit"
    End With

    intBeforeIndex = intBeforeIndex + 1
    Set cmdbutton = cmdbar.Controls.Add(Type:=msoControlButton, Temporary:=False, Before:=intBeforeIndex, ID:=748)
    With cmdbutton
    .Style = msoButtonCaption
    .Caption = "FileSaveAs"
    .TooltipText = "FileSaveAs"
    End With

    intBeforeIndex = intBeforeIndex + 1
    Set cmdbutton = cmdbar.Controls.Add(Type:=msoControlButton, Temporary:=False, Before:=intBeforeIndex, ID:=37)
    With cmdbutton
    .TooltipText = "EditRepeat"
    End With

    tmpActive.Save

    Set tmpActive = Nothing
    Set cmdbar = Nothing
    Set cmdbutton = Nothing
    End Sub
    </pre>


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

    Re: CommandBars: Top property (Word)

    It's been suggested that 3rd party software may cause this problem.

    I rebooted to a system with Office 2000.
    The problem did not occur using Word 2000.

    However, this is not ceteris paribus.
    The Office 2000 system has Acrobat 4 and NAV 2003, the Office 2003 system has Acrobat 5 and NAV 2004.
    The Office 2003 system has Omni Page Pro Office 14, the other does not.
    Etc.

    I guess I have to write this issue off to the effect of some 3rd party
    software.

    P.S. Same problem occurs if I use msoBarTop.

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

    Re: CommandBars: Top property (Word)

    I found an odd workaround, which implies that the problem is with Word, not with any 3rd party software.

    Originally, I was creating a toolbar with several msoControlButton controls.

    If I instead did the following, then the toolbar placement is correct.

    Instead of directly placing the button controls on the toolbar, I put a single popup control on the toolbar and then placed the buttons on that single popup control.

    Why the latter would cause proper toolbar placement and not the former is beyond my comprehension.
    Do not see how 3rd party software could be the issue.

    This makes no sense (to me).

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

    Re: CommandBars: Top property (Word)

    I spoke too soon.

    Problem came back.

    Uncle!

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

    Re: CommandBars: Top property (Word)

    Well, I again spoke too soon!
    Problem has gone away!

    Aunt!!!!

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CommandBars: Top property (Word)

    > both toolbars appear on the same row

    I wish!

    My code, attached, is from ExcelXP. I'm creating a command bar for each of my utility applications, and decided that as each application loaded and created its command bar, (thanks again <!post=Jan Karel,493093>Jan Karel<!/post> ), I'd align everything neatly. I can't get the bars to sit beside each other. They insist on separate rows (see image below).

    If I set the type to msoFloating I get more control over position, but the floaters hide some part of the workbook screen.

    I tried your code in WordXP and found that with each run of the macro "CommandBarTop", the two commandbars stacked an extra copy, one atop the other, not side by side.

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

    Re: CommandBars: Top property (Word)

    Your attachment doesn't contain code.

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CommandBars: Top property (Word)

    <!post=Kevin,34622>Kevin<!/post> answered my question: <pre>obar.RowIndex = 25</pre>

    does the trick in my Excel/XP code.

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CommandBars: Top property (Word)

    Here is my (attached) VBA code module from Excel/XP

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CommandBars: Top property (Word)

    > Your attachment doesn't contain code.

    Thank you, Hans. Wrong file. Long day, ..... now fixed.

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

    Re: CommandBars: Top property (Word)

    Does <post#=495077>post 495077</post#> mean that you don't expect a reply to <post#=495070>post 495070</post#>/<post#=495072>post 495072</post#> any more?

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: CommandBars: Top property (Word)

    > Does post 495077 mean that you don't expect a reply to post 495070/post 495072 any more?

    Now you are confusing me! I think that the answer is YES. But let's hear from Howard.

    Thanks again for hatching the attachment catchment.

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

    Re: CommandBars: Top property (Word)

    In my example, the command bars are not supposed to be side by side.

    I ws not talking about Excel, just Word.

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

    Re: CommandBars: Top property (Word)

    Sorry, but I'm out of this fer a while.

    My mother died today and I'm rather tied up with other things.

    If I remember, I'll come back to this thread, but don't count on it.

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

    Re: CommandBars: Top property (Word)

    Note to those commenting on my orioginal posting.

    The subject is Word, not Excel.

Posting Permissions

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