-
Notifications
You must be signed in to change notification settings - Fork 2
/
menu.bas
49 lines (40 loc) · 1.52 KB
/
menu.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Attribute VB_Name = "menu"
Option Explicit
' This file is part of the Minnesota Population Center's VBA libraries project.
' For copyright and licensing information, see the NOTICE and LICENSE files
' in this project's top-level directory, and also on-line at:
' https://github.com/mnpopcenter/vba-libs
' Module dependencies:
' bootstrap (CurrentMode, ToolkitMode, CurrentEdition, ToolkitEdition)
' conf
' Excel_version
' menu_library
Private myMenuName As String
Public Sub CreateToolkitMenu(ByRef definition() As String)
myMenuName = conf.MENU_NAME
If CurrentMode = ToolkitMode.Development Then
myMenuName = myMenuName & " (dev)"
ElseIf CurrentEdition = ToolkitEdition.BuiltProduction Then
myMenuName = myMenuName & " (prod)"
End If
If CurrentMode = ToolkitMode.Development Then
EnableDevelopersMenu definition
End If
' Workaround for bug with menus not being removed when an add-in closes.
' https://support.microsoft.com/en-us/kb/2761240
If ExcelVersionIs(ExcelWin, 2013) Then
' Remove any menus left over from the previous Excel session
RemoveToolkitMenu
End If
AddCustomMenu myMenuName, definition
End Sub
Public Sub RemoveToolkitMenu()
RemoveCustomMenu myMenuName
End Sub
Sub EnableDevelopersMenu(definition() As String)
' Remove any "#dev>" markers to enable the developers menu
Dim i As Integer
For i = LBound(definition) To UBound(definition)
definition(i) = Replace(definition(i), "#dev>", "")
Next i
End Sub