#1   Report Post  
Posted to microsoft.public.excel.programming
bmm bmm is offline
external usenet poster
 
Posts: 10
Default ToolBar

How can I add a new tool bar to the Excel using VBA.
One way tried is read the resource file and copy on clipboard and paste it
on command bar.
But when we open more than one instances of XL, tool bar is not visible in
all of them completely.

How can we handle this?

Thanks and rgds




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ToolBar

Here is some sample code to create a toolbar button on the Formatting
toolbar. This code would go in the ThisWorkbok code module of the addin.

To create your own toolbar, just add

On Error Resume Next
Application.CommandBars("myToolbar").Delete
On Error GoTo 0

Set oCB = Application.CommandBars.add("myToolbar", temporary:=true)
Set oCtl = oCB.Controls.Add(Type:=msoControlButton, temporary:=True)

in place of the code that gets the formatting CB. Change the delete in
BeforeClose as well

I would also add my usual corollary that to see what FaceIds are available,
visit John Walkenbach's site at http://j-walk.com/ss/excel/tips/tip67.htm

Option Explicit

Dim sMenu As String

Private Sub Workbook_BeforeClose(Cancel As Boolean)

sMenu = "myButton"

On Error Resume Next
Application.CommandBars("Formatting").Controls(sMe nu).Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
Dim oCtl As CommandBarControl
Dim newMenu As Object 'CommandBarControl
Dim ctrlButton As Object 'CommandBarControl

sMenu = "Margin Calculator"

On Error Resume Next
Application.CommandBars("Formatting").Controls(sMe nu).Delete
On Error GoTo 0

Set oCB = Application.CommandBars("Formatting")
Set oCtl = oCB.Controls.Add(Type:=msoControlButton, temporary:=True)

With oCtl
.BeginGroup = True
.Caption = sMenu
.FaceId = 197
.Style = msoButtonIconAndCaption
.OnAction = "myMacro"
End With

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"bmm" <newsgroup.com wrote in message
...
How can I add a new tool bar to the Excel using VBA.
One way tried is read the resource file and copy on clipboard and paste it
on command bar.
But when we open more than one instances of XL, tool bar is not visible in
all of them completely.

How can we handle this?

Thanks and rgds






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
excel toolbar like word toolbar, please Meng[_2_] Excel Discussion (Misc queries) 1 May 23rd 09 04:28 PM
Form Toolbar verses Control Toolbar ub Excel Discussion (Misc queries) 3 July 11th 08 10:57 PM
Adjusting toolbar size, restore toolbar Josh M Excel Discussion (Misc queries) 1 January 18th 06 06:17 PM
How can I keep Toolbar Buttons on the toolbar? weberts2 Setting up and Configuration of Excel 1 July 16th 05 04:30 AM
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 03:16 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"