Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
TAL27
 
Posts: n/a
Default making your own menus on excel?


Is it possible? I'd like to make one where you can open up various
submenus, and eventually select an option that has a macro
attached....(like eg the 'all programs' menu that branches off the
'start' option on windows. SURELY that's possible!

Cheers,

Tom


--
TAL27
------------------------------------------------------------------------
TAL27's Profile: http://www.excelforum.com/member.php...o&userid=30145
View this thread: http://www.excelforum.com/showthread...hreadid=498749

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default making your own menus on excel?

Here is an example

Option Explicit

'If you put code in the appropriate workbook open event, and
'delete it in the close it will exist only for that workbook.

'Here is an example of a building a commandbar on the fly
'when you open a workbook. It adds a sub-menu to the Tools menu.

Private Sub Workbook_Open()
Dim oCb As CommandBar
Dim oCtl As CommandBarPopup
Dim oCtlBtn As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls("Tools").Controls.Add( _
Type:=msoControlPopup, _
temporary:=True)
oCtl.Caption = "myButton"
With oCtl
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtlBtn.Caption = "myMacroButton"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myMacro"
End With
With oCtl
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtlBtn.Caption = "myMacroButton2"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myMacro2"
End With
'etc.
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCb As CommandBar

Set oCb = Application.CommandBars("Worksheet Menu Bar")
oCb.Controls("Tools").Controls("myButton").Delete
End Sub

'To add this, go to the VB IDE (ALT-F11 from Excel), and in
'the explorer pane, select your workbook. Then select the
'ThisWorkbook object (it's in Microsoft Excel Objects which
'might need expanding). Double-click the ThisWorkbook and
'a code window will open up. Copy this code into there,
'changing the caption and action to suit.

'This is part of the workbook, and will only exist with the
'workbook, but will be available to anyone who opens the
'workbook.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"TAL27" wrote in message
...

Is it possible? I'd like to make one where you can open up various
submenus, and eventually select an option that has a macro
attached....(like eg the 'all programs' menu that branches off the
'start' option on windows. SURELY that's possible!

Cheers,

Tom


--
TAL27
------------------------------------------------------------------------
TAL27's Profile:

http://www.excelforum.com/member.php...o&userid=30145
View this thread: http://www.excelforum.com/showthread...hreadid=498749



  #3   Report Post  
Posted to microsoft.public.excel.misc
TAL27
 
Posts: n/a
Default making your own menus on excel?


Thanks Bob - have copied in the code you gave, but can't really see what
difference it has made. Has something appeared on the Tools menu? I
can't see a new option?

Cheers,

Tom

PS sorry about late reply - haven't been able to access internet
lately.


--
TAL27
------------------------------------------------------------------------
TAL27's Profile: http://www.excelforum.com/member.php...o&userid=30145
View this thread: http://www.excelforum.com/showthread...hreadid=498749

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 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
create menus in excel worksheet Anthony Excel Worksheet Functions 1 February 23rd 05 03:04 PM
Making A Databse system on Excel? Lwotton Excel Discussion (Misc queries) 2 January 4th 05 03:27 PM
Making text all CAPS in excel Jon Excel Worksheet Functions 4 December 13th 04 09:06 PM
how do you create drop down menus for individual cells in excel? Frosty1 Excel Worksheet Functions 2 November 15th 04 11:02 PM


All times are GMT +1. The time now is 11:18 PM.

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"