-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExcel4AModule2.bas
37 lines (25 loc) · 978 Bytes
/
Excel4AModule2.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
Attribute VB_Name = "Module2"
Option Explicit
Sub BuildCustomMenuFndLogFile()
Dim ContextMenu As CommandBar
Call DeleteCustomMenuFndLogFile
Set ContextMenu = Application.CommandBars("List Range Popup")
With ContextMenu.Controls.Add(Temporary:=True, Before:=1)
.OnAction = "'" & ThisWorkbook.Name & "'!" & "LogAggregation_FindLogFileFromLocalTS"
.Style = msoButtonCaption
.Caption = "Find Log File"
.Tag = "FindLogFileFromLocalTS_Tag"
End With
End Sub
Sub DeleteCustomMenuFndLogFile()
Dim ContextMenu As CommandBar
Dim ctrl As CommandBarControl
' Set ContextMenu to the Cell context menu.
Set ContextMenu = Application.CommandBars("List Range Popup")
' Delete the custom controls with the Tag : My_Cell_Control_Tag.
For Each ctrl In ContextMenu.Controls
If ctrl.Tag = "FindLogFileFromLocalTS_Tag" Then
ctrl.Delete
End If
Next ctrl
End Sub