Cứ mỗi lần mở file là Name Manager có sẵn trong tools, mặc dù tôi đã gỡ trong AddIns. Và cứ mỗi lần mở Name Manager là trong menu Tools hiện thêm 1 dòng Name Manager. Xin giải pháp bỏ, thấy rất khó chịu.
Xin cám ơn!
Xin cám ơn!
Private Sub Workbook_Open()
' This sub is executed when the workbook (or add-in) is opened
''''''''''''''''''''''''''''''''''''''''''''''''''
' Change the following variables to customize...
XLCommandBar = "Worksheet Menu Bar"
XLMenu = "Tools"
XLMenuItem = ""
NewMenuItem = "&Name Manager..."
NewMenuItemMacro = "StartNameLister"
''''''''''''''''''''''''''''''''''''''''''''''''''
Dim NewItem As CommandBarButton
' Delete the current menu if it exists (just in case)
On Error Resume Next
Application.CommandBars(XLCommandBar).Controls(XLMenu).Controls(XLMenuItem).Controls(NewMenuItem).Delete
Application.CommandBars(XLCommandBar).Controls(XLMenu).Controls(NewMenuItem).Delete
On Error GoTo 0
' Create the new menu item
If XLMenuItem = "" Then
Set NewItem = Application.CommandBars(XLCommandBar).Controls(XLMenu).Controls.Add
Else
Set NewItem = Application.CommandBars(XLCommandBar).Controls(XLMenu).Controls(XLMenuItem).Controls.Add
End If
' Specify the Caption and OnAction properties
With NewItem
.Caption = NewMenuItem
.OnAction = NewMenuItemMacro 'This sub is in Module1
.FaceId = 0 'This is the image displayed next to the the menu item text
.BeginGroup = True ' Add a separator bar before the menu item
End With
Exit Sub
' If an error occured, tell the user
If Err <> 0 Then
MsgBox "An error occurred.", vbInformation
End If
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
' This sub is executed when the workbook (or add-in) is closed.
' It simply removes the menu item from the Data menu
On Error Resume Next
Application.CommandBars(XLCommandBar).Controls(XLMenu).Controls(XLMenuItem).Controls(NewMenuItem).Delete
Application.CommandBars(XLCommandBar).Controls(XLMenu).Controls(NewMenuItem).Delete
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
' This sub is executed when the workbook (or add-in) is closed.
' It simply removes the menu item from the Data menu
XLCommandBar = "Worksheet Menu Bar"
XLMenu = "Tools"
XLMenuItem = ""
NewMenuItem = "&Name Manager..."
NewMenuItemMacro = "StartNameLister"
On Error Resume Next
Application.CommandBars(XLCommandBar).Controls(XLMenu).Controls(XLMenuItem).Controls(NewMenuItem).Delete
Application.CommandBars(XLCommandBar).Controls(XLMenu).Controls(NewMenuItem).Delete
End Sub