Skip to content

Commit

Permalink
Fix issue #4 - menu bug when language is German
Browse files Browse the repository at this point in the history
Changed the default behavior for finding the Help menu -- we now look it
by its control id (which is language-independent).  This change still
needs to be verified with a non-English version of Excel.
  • Loading branch information
jimm-domingo committed Nov 1, 2016
1 parent cc1bf86 commit 4a881c5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions menu_lib.bas
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ Option Explicit
' submenu separator must be indented at least 4 spaces.
'
Sub AddCustomMenu(menuName As String, definition() As String, _
Optional insertBefore As String = "Help")
Dim helpMenuIndex As Integer
Optional insertBefore As String = "")
Dim helpMenu As CommandBarControl
Dim customMenu As CommandBarControl
Dim mainMenuBar As CommandBar

Set mainMenuBar = Application.CommandBars("Worksheet Menu Bar")
helpMenuIndex = mainMenuBar.Controls(insertBefore).Index
If insertBefore = "" Then
' By default, look up Help menu by its control id since its name
' is language-dependent
Set helpMenu = mainMenuBar.FindControl(ID:=30010)
Else
Set helpMenu = mainMenuBar.Controls(insertBefore)
End If
Set customMenu = mainMenuBar.Controls.Add(Type:=msoControlPopup, _
Before:=helpMenuIndex)
Before:=helpMenu.Index)
customMenu.Caption = menuName

Dim line As String
Expand Down

0 comments on commit 4a881c5

Please sign in to comment.