Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
AC AC is offline
external usenet poster
 
Posts: 7
Default how do i add dropdown menus to a menu bar?

Hi

I have added a menu bar with buttons which run code when clicked.
What i want to do is add dropdown menus which have their own sub
'buttons' on them. Just like when you click the File on the standard
menu in Excel, and it drops down and shows New, Open etc.

My current code is (i am only showing the code for a couple of the
buttons I am adding):

PerformCommandBar As CommandBar
Set PerformCommandBar = Application.CommandBars.Add(ToolbarName,
msoBarFloating, False, True)
PerformCommandBar.Visible = True
Set NewItem = PerformCommandBar.Controls.Add(msoControlButton)
With NewItem
.Caption = "Delete Data"
.TooltipText = "Delete all the data sheets"
.OnAction = "DeleteDataSheets"
.Style = msoButtonCaption
.Visible = True
End With
Set NewItem = PerformCommandBar.Controls.Add(msoControlButton)
With NewItem
.Caption = "Text to Formulas"
.TooltipText = "Change the formulas in the Calc sheet back
from text"
.OnAction = "Copy_Text_to_Formulas"
.Style = msoButtonCaption
.Visible = True
End With


All help appreciated

AndyC
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 703
Default how do i add dropdown menus to a menu bar?

Hi

This should get you started:

APPNAME=ToolbarName
On Error Resume Next
Application.CommandBars(APPNAME).Delete

'Create MenuBar
Set MyMenuBar = Application.CommandBars.Add(APPNAME,
Position:=msoBarTop, temporary:=False)
MyMenuBar.Visible = True

' Create a popup control
Set cbPop = Application.CommandBars(APPNAME).Controls.Add
(Type:=msoControlPopup)
cbPop.Caption = APPNAME
cbPop.Visible = True

'------------------------------------------------
' Sub Menu
'------------------------------------------------

Set cbCtl = cbPop.Controls.Add(Type:=msoControlButton)
With cbCtl
.Visible = True
.Style = msoButtonCaption
.Caption = "&Delete Data"
.OnAction = "DeleteDataSheets"
End With

Best regards,
Per

On 21 Jun., 00:57, AC wrote:
Hi

I have added a menu bar with buttons which run code when clicked.
What i want to do is add dropdown menus which have their own sub
'buttons' on them. *Just like when you click the File on the standard
menu in Excel, and it drops down and shows New, Open etc.

My current code is (i am only showing the code for a couple of the
buttons I am adding):

PerformCommandBar As CommandBar
Set PerformCommandBar = Application.CommandBars.Add(ToolbarName,
msoBarFloating, False, True)
* * * * PerformCommandBar.Visible = True
Set NewItem = PerformCommandBar.Controls.Add(msoControlButton)
* * * * With NewItem
* * * * * * .Caption = "Delete Data"
* * * * * * .TooltipText = "Delete all the data sheets"
* * * * * * .OnAction = "DeleteDataSheets"
* * * * * * .Style = msoButtonCaption
* * * * * * .Visible = True
* * * * End With
* * * * Set NewItem = PerformCommandBar.Controls.Add(msoControlButton)
* * * * With NewItem
* * * * * * .Caption = "Text to Formulas"
* * * * * * .TooltipText = "Change the formulas in the Calc sheet back
from text"
* * * * * * .OnAction = "Copy_Text_to_Formulas"
* * * * * * .Style = msoButtonCaption
* * * * * * .Visible = True
* * * * End With

All help appreciated

AndyC


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
select From dropdown and return another dropdown menu RE4379 Excel Discussion (Misc queries) 2 March 11th 10 03:09 PM
in-cell dropdown menus mahmoud Excel Discussion (Misc queries) 2 December 17th 08 02:59 PM
Excel dropdown menus RICKZ Setting up and Configuration of Excel 1 September 7th 08 11:55 AM
Help with dropdown menus [email protected] Excel Programming 4 August 24th 05 10:18 PM
Overriding Actions of Excel DropDown Menus and Poup Menus Von Shean Excel Programming 2 February 3rd 04 06:43 AM


All times are GMT +1. The time now is 09:03 AM.

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

About Us

"It's about Microsoft Excel"