Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Command Bars

With the macro below is there a way to add a custom button to the
Toolbar without deleing then recreating it?

Sub CreateOtherCommandBar_Test1()
On Error Resume Next
Application.CommandBars(TBN).Delete
On Error GoTo 0
With Application.CommandBars.Add
.Name = TBN
.Visible = True
With .Controls.Add(Type:=msoControlPopup, Befo=1)
.Caption = "Menu 1"
With .Controls.Add(Type:=msoControlButton, Befo=1)
.Caption = "Btn 1"
End With
With .Controls.Add(Type:=msoControlButton, Befo=2)
.Caption = "Btn 2"
End With
End With
End With
End Sub

Thank you for your help,
jfcby
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Command Bars

jfcby,

Question:
With the macro above is there a way to add a custom button to the
Toolbar without deleing then recreating it?

Answer:

Yes, with the macro below.

<MACRO CODE

Sub CreateOtherCommandBar_AddToolBarControls()
'Add toolbar controls
Dim Cmdb
Set Cmdb = CommandBars(TBN).FindControl(Type:=msoControlPopup ,
ID:=1)

With Cmdb.Controls.Add(Type:=msoControlButton)
.Caption = "Btn 4"
End With
End Sub

<MACRO CODE

Thank you for your help and response,
jfcby


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Command Bars

A better solution to add custom buttons to the toolbar:

<MACRO CODE

Sub CreateOtherCommandBar_AddToolBarControlsEx2()
'Add toolbar controls
Dim ctrl
On Error Resume Next
Set ctrl = CommandBars(TBN).Controls("Sort Options") _
'.Controls("My Personal Tools ")
On Error GoTo 0
If ctrl Is Nothing Then
MsgBox "Control does not exist"
Else
With ctrl.Controls.Add(Type:=msoControlButton)
.Caption = "Btn 4"
End With
End If

End Sub

<MACRO CODE
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Command Bars

Check your other post.

jfcby wrote:

With the macro below is there a way to add a custom button to the
Toolbar without deleing then recreating it?

Sub CreateOtherCommandBar_Test1()
On Error Resume Next
Application.CommandBars(TBN).Delete
On Error GoTo 0
With Application.CommandBars.Add
.Name = TBN
.Visible = True
With .Controls.Add(Type:=msoControlPopup, Befo=1)
.Caption = "Menu 1"
With .Controls.Add(Type:=msoControlButton, Befo=1)
.Caption = "Btn 1"
End With
With .Controls.Add(Type:=msoControlButton, Befo=2)
.Caption = "Btn 2"
End With
End With
End With
End Sub

Thank you for your help,
jfcby


--

Dave Peterson
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
Command Bars KneeDown2Up Excel Discussion (Misc queries) 4 January 16th 07 06:43 PM
Command Bars Bill[_30_] Excel Programming 1 October 5th 05 08:16 PM
Command Bars Neil Hopkinson[_2_] Excel Programming 3 August 19th 05 09:53 AM
Command Bars nath Excel Programming 2 August 23rd 04 01:45 PM
command bars Geo Siggy[_16_] Excel Programming 6 April 22nd 04 10:50 AM


All times are GMT +1. The time now is 04:12 PM.

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"