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

I have search on old posts on this topic and there are a lot of information
but maybe I need more basics on this... I have tried several of the options
but can not make appear any new command on my excel file command bar...

I have Excel 2002.... I copied below code from "Roman" from a post back in
2005 but not working for me.... maybe I am not loading it in the right
place... I try a module, I try in Private Sub Workbook_Open(), and try
whatever but not luck :(

Need help to create a new menu on my command bar that will work just with a
specific file...

Appreciate help

Sub makemenewbar()
Set mynewbar = CommandBars(1).Controls.Add(Type:=msoControlPopup,
Temporary:=True)
With mynewbar
...Caption = "Name of new bar"
End With

Set button1 = mynewbar.Controls.Add(Type:=msoControlButton)
With button1
.Caption = "Button1"
.OnAction = "macro1"
End With

Set mysubmenu = mynewbar.Controls.Add(Type:=msoControlPopup)
With mysubmenu
.Caption = "Submenu1"
'.OnAction = "sheets_startuf"
End With

Set button2 = mysubmenu.Controls.Add(Type:=msoControlButton)
With button2
.Caption = "Button2 name"
.OnAction = "macro2"
End With

Set button3 = mysubmenu.Controls.Add(Type:=msoControlButton)
With button3
.Caption = "Button3 name"
.OnAction = "macro3"
End With
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Command Bar Creation

The code works fine for me, it puts a popup button on the main with some
other buttons.
Probably best to put the code in a normal module and test it. Leave the code
in the normal module and call from your open event.

Additionally, you might want to ensure the menu is deleted before attempting
to recreate it, eg

On Error Resume Next
CommandBars(1).Controls("Name of new bar").Delete
On Error GoTo 0

In your post there are two dots before ..Caption, I assume there's only one
in your actual code

Regards,
Peter T



"Alberto Ast" wrote in message
...
I have search on old posts on this topic and there are a lot of information
but maybe I need more basics on this... I have tried several of the
options
but can not make appear any new command on my excel file command bar...

I have Excel 2002.... I copied below code from "Roman" from a post back in
2005 but not working for me.... maybe I am not loading it in the right
place... I try a module, I try in Private Sub Workbook_Open(), and try
whatever but not luck :(

Need help to create a new menu on my command bar that will work just with
a
specific file...

Appreciate help

Sub makemenewbar()
Set mynewbar = CommandBars(1).Controls.Add(Type:=msoControlPopup,
Temporary:=True)
With mynewbar
..Caption = "Name of new bar"
End With

Set button1 = mynewbar.Controls.Add(Type:=msoControlButton)
With button1
.Caption = "Button1"
.OnAction = "macro1"
End With

Set mysubmenu = mynewbar.Controls.Add(Type:=msoControlPopup)
With mysubmenu
.Caption = "Submenu1"
'.OnAction = "sheets_startuf"
End With

Set button2 = mysubmenu.Controls.Add(Type:=msoControlButton)
With button2
.Caption = "Button2 name"
.OnAction = "macro2"
End With

Set button3 = mysubmenu.Controls.Add(Type:=msoControlButton)
With button3
.Caption = "Button3 name"
.OnAction = "macro3"
End With
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default Command Bar Creation

Thanks Peter, got it.

"Peter T" wrote:

The code works fine for me, it puts a popup button on the main with some
other buttons.
Probably best to put the code in a normal module and test it. Leave the code
in the normal module and call from your open event.

Additionally, you might want to ensure the menu is deleted before attempting
to recreate it, eg

On Error Resume Next
CommandBars(1).Controls("Name of new bar").Delete
On Error GoTo 0

In your post there are two dots before ..Caption, I assume there's only one
in your actual code

Regards,
Peter T



"Alberto Ast" wrote in message
...
I have search on old posts on this topic and there are a lot of information
but maybe I need more basics on this... I have tried several of the
options
but can not make appear any new command on my excel file command bar...

I have Excel 2002.... I copied below code from "Roman" from a post back in
2005 but not working for me.... maybe I am not loading it in the right
place... I try a module, I try in Private Sub Workbook_Open(), and try
whatever but not luck :(

Need help to create a new menu on my command bar that will work just with
a
specific file...

Appreciate help

Sub makemenewbar()
Set mynewbar = CommandBars(1).Controls.Add(Type:=msoControlPopup,
Temporary:=True)
With mynewbar
..Caption = "Name of new bar"
End With

Set button1 = mynewbar.Controls.Add(Type:=msoControlButton)
With button1
.Caption = "Button1"
.OnAction = "macro1"
End With

Set mysubmenu = mynewbar.Controls.Add(Type:=msoControlPopup)
With mysubmenu
.Caption = "Submenu1"
'.OnAction = "sheets_startuf"
End With

Set button2 = mysubmenu.Controls.Add(Type:=msoControlButton)
With button2
.Caption = "Button2 name"
.OnAction = "macro2"
End With

Set button3 = mysubmenu.Controls.Add(Type:=msoControlButton)
With button3
.Caption = "Button3 name"
.OnAction = "macro3"
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
print command from command button in userform causes double chart Mike Jamesson Excel Programming 5 August 11th 09 03:42 AM
BUG: print command from command button in userform causes double c Mike Jamesson Excel Programming 0 August 10th 09 04:19 PM
Pivot Table Error Message - "Command Text not set for command obje Jeff Divian Excel Discussion (Misc queries) 0 November 7th 07 10:26 PM
Wanting to Create A Command Button Command bumper338 Excel Programming 3 May 7th 07 06:53 PM
Excel to load COMMAND and type a Run Command? [email protected] Excel Programming 5 August 22nd 06 10:47 PM


All times are GMT +1. The time now is 05:01 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"