Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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"
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   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default 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"
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   Report Post  
Posted to microsoft.public.excel.programming
Wei Wei is offline
external usenet poster
 
Posts: 8
Default docking a custom toolbar

JNW,
I met the similar problem, the only different is that I need to dock the
toolbar at the right bottom of Excel. I am a newbie of Excel VBA, can you
elaborate how did you make it work?
Thanks!
Wei

"JNW" wrote:

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"
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Docking a Toolbar and having it stay Access101 Excel Discussion (Misc queries) 6 August 28th 08 07:10 PM
Toolbar Re-Docking Robert11 New Users to Excel 1 February 2nd 07 03:28 PM
VBA - Disappearing custom menu and custom toolbar Peter[_50_] Excel Programming 2 December 2nd 04 06:09 PM
custom toolbar buttons are saved where? Excel loads twice bymistake and all my custom toolbar buttons get gone!!! Kevin Waite Excel Programming 2 March 3rd 04 03:31 PM
saving toolbar buttons on custom toolbar Paul James Excel Programming 12 August 6th 03 08:28 AM


All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"