+ Reply to Thread
Results 1 to 4 of 4

docking a custom toolbar

  1. #1
    JNW
    Guest

    docking a custom toolbar

    Can a toolbar be docked?

    I've created an add-in that creates a toolbar then it adds two buttons. All
    this works perfect. I would like for the toolbar to automatically dock, or
    once docked the first time by the user it will always remain there when Excel
    is opened (like all the rest of the toolbars.

    Any ideas? (see my code below)

    Private Sub Workbook_Open()
    Application.CommandBars("CN Tools").Delete

    Set cmdCN = Application.CommandBars.Add("CN Tools", , , False)

    With cmdCN
    .Visible = True

    'CreateRedUnderlineButton
    With .Controls.Add(Type:=msoControlButton)
    .TooltipText = "Underlines number in red"
    .Picture = LoadPicture("H:\Tax return underline icon.bmp")
    .OnAction = "NumberForTaxReturn"
    End With

    'Create button to number sheets
    With .Controls.Add(Type:=msoControlButton)
    .TooltipText = "Numbers all sheets in workbook"
    .OnAction = "NumberAllSheetsInWorkbook"
    .Picture = LoadPicture("H:\Number Sheets icon.bmp")
    End With
    End With
    End Sub


  2. #2
    Jim Cone
    Guest

    Re: docking a custom toolbar

    Use the Position property...
    ..Position = msoBarTop

    -and the RowIndex property...
    ..RowIndex = Application.CommandBars("Formatting").RowIndex

    Also, you may have to set the .Left property.
    --
    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware


    "JNW" <[email protected]>
    wrote in message
    Can a toolbar be docked?
    I've created an add-in that creates a toolbar then it adds two buttons. All
    this works perfect. I would like for the toolbar to automatically dock, or
    once docked the first time by the user it will always remain there when Excel
    is opened (like all the rest of the toolbars.
    Any ideas? (see my code below)

    Private Sub Workbook_Open()
    Application.CommandBars("CN Tools").Delete

    Set cmdCN = Application.CommandBars.Add("CN Tools", , , False)

    With cmdCN
    .Visible = True

    'CreateRedUnderlineButton
    With .Controls.Add(Type:=msoControlButton)
    .TooltipText = "Underlines number in red"
    .Picture = LoadPicture("H:\Tax return underline icon.bmp")
    .OnAction = "NumberForTaxReturn"
    End With

    'Create button to number sheets
    With .Controls.Add(Type:=msoControlButton)
    .TooltipText = "Numbers all sheets in workbook"
    .OnAction = "NumberAllSheetsInWorkbook"
    .Picture = LoadPicture("H:\Number Sheets icon.bmp")
    End With
    End With
    End Sub


  3. #3
    JNW
    Guest

    Re: docking a custom toolbar

    That did the trick. I added the position along with rowIndex. And to top it
    off a Left = 1 to set it after the formatting bar.

    Thanks!
    --
    JNW


    "Jim Cone" wrote:

    > Use the Position property...
    > ..Position = msoBarTop
    >
    > -and the RowIndex property...
    > ..RowIndex = Application.CommandBars("Formatting").RowIndex
    >
    > Also, you may have to set the .Left property.
    > --
    > Jim Cone
    > San Francisco, USA
    > http://www.realezsites.com/bus/primitivesoftware
    >
    >
    > "JNW" <[email protected]>
    > wrote in message
    > Can a toolbar be docked?
    > I've created an add-in that creates a toolbar then it adds two buttons. All
    > this works perfect. I would like for the toolbar to automatically dock, or
    > once docked the first time by the user it will always remain there when Excel
    > is opened (like all the rest of the toolbars.
    > Any ideas? (see my code below)
    >
    > Private Sub Workbook_Open()
    > Application.CommandBars("CN Tools").Delete
    >
    > Set cmdCN = Application.CommandBars.Add("CN Tools", , , False)
    >
    > With cmdCN
    > .Visible = True
    >
    > 'CreateRedUnderlineButton
    > With .Controls.Add(Type:=msoControlButton)
    > .TooltipText = "Underlines number in red"
    > .Picture = LoadPicture("H:\Tax return underline icon.bmp")
    > .OnAction = "NumberForTaxReturn"
    > End With
    >
    > 'Create button to number sheets
    > With .Controls.Add(Type:=msoControlButton)
    > .TooltipText = "Numbers all sheets in workbook"
    > .OnAction = "NumberAllSheetsInWorkbook"
    > .Picture = LoadPicture("H:\Number Sheets icon.bmp")
    > End With
    > End With
    > End Sub
    >
    >


  4. #4
    JNW
    Guest

    Re: docking a custom toolbar

    That did the trick. I added the position along with rowIndex. And to top it
    off a Left = 1 to set it after the formatting bar.

    Thanks!
    --
    JNW


    "Jim Cone" wrote:

    > Use the Position property...
    > ..Position = msoBarTop
    >
    > -and the RowIndex property...
    > ..RowIndex = Application.CommandBars("Formatting").RowIndex
    >
    > Also, you may have to set the .Left property.
    > --
    > Jim Cone
    > San Francisco, USA
    > http://www.realezsites.com/bus/primitivesoftware
    >
    >
    > "JNW" <[email protected]>
    > wrote in message
    > Can a toolbar be docked?
    > I've created an add-in that creates a toolbar then it adds two buttons. All
    > this works perfect. I would like for the toolbar to automatically dock, or
    > once docked the first time by the user it will always remain there when Excel
    > is opened (like all the rest of the toolbars.
    > Any ideas? (see my code below)
    >
    > Private Sub Workbook_Open()
    > Application.CommandBars("CN Tools").Delete
    >
    > Set cmdCN = Application.CommandBars.Add("CN Tools", , , False)
    >
    > With cmdCN
    > .Visible = True
    >
    > 'CreateRedUnderlineButton
    > With .Controls.Add(Type:=msoControlButton)
    > .TooltipText = "Underlines number in red"
    > .Picture = LoadPicture("H:\Tax return underline icon.bmp")
    > .OnAction = "NumberForTaxReturn"
    > End With
    >
    > 'Create button to number sheets
    > With .Controls.Add(Type:=msoControlButton)
    > .TooltipText = "Numbers all sheets in workbook"
    > .OnAction = "NumberAllSheetsInWorkbook"
    > .Picture = LoadPicture("H:\Number Sheets icon.bmp")
    > End With
    > End With
    > End Sub
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1