ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Custom Menus With Excel 2007 (https://www.excelbanter.com/excel-programming/400996-custom-menus-excel-2007-a.html)

Mike H.

Custom Menus With Excel 2007
 
Recently some users got new PC's with Vista and Excel 2007. Now this macro
does not build a custom menu when the file is opened? Can I have my code
detect the version of Excel and then is there a modified version of this
menu-building macro for Excel 2007?

Private Sub Workbook_Open()

Dim Menu1 As CommandBarControl
Dim MainMenuBar As CommandBar
Dim CustomMenu As CommandBarControl
On Error Resume Next
Application.CommandBars("Worksheet Menu
Bar").Controls("&JournalEntries").Delete
On Error GoTo 0
Set MainMenuBar = Application.CommandBars("Worksheet Menu Bar")
HelpMenu = MainMenuBar.Controls("Help").Index
Set CustomMenu = MainMenuBar.Controls.Add(Type:=msoControlPopup,
Befo=HelpMenu)
CustomMenu.Caption = "&JournalEntries"
With CustomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "ValidateJE"
.OnAction = "ValidateOneJe"
End With


Jim Rech[_2_]

Custom Menus With Excel 2007
 
Now this macro does not build a custom menu when the file is opened?

It does but you have to switch to the Add-ins tab to find it.


--
Jim
"Mike H." wrote in message
...
Recently some users got new PC's with Vista and Excel 2007. Now this
macro
does not build a custom menu when the file is opened? Can I have my code
detect the version of Excel and then is there a modified version of this
menu-building macro for Excel 2007?

Private Sub Workbook_Open()

Dim Menu1 As CommandBarControl
Dim MainMenuBar As CommandBar
Dim CustomMenu As CommandBarControl
On Error Resume Next
Application.CommandBars("Worksheet Menu
Bar").Controls("&JournalEntries").Delete
On Error GoTo 0
Set MainMenuBar = Application.CommandBars("Worksheet Menu Bar")
HelpMenu = MainMenuBar.Controls("Help").Index
Set CustomMenu = MainMenuBar.Controls.Add(Type:=msoControlPopup,
Befo=HelpMenu)
CustomMenu.Caption = "&JournalEntries"
With CustomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "ValidateJE"
.OnAction = "ValidateOneJe"
End With





All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com