H
HenrikH
Hi i've have a macro setting up a custom menu item in the Files, Send
To menu (ie in at submenu to the files menu).
The macro is set in the ThisWorkbook section but i cannot figure out
how to delete it again (i get multiple items of it).
The code looks like this:
' Code for creating the menu item
Sub InsertMenuItem()
Dim RowMenu As CommandBarControl
Dim NewMenuItem As CommandBarButton
'Find menuitem Row
Set RowMenu = CommandBars(1).FindControl(ID:=30095,
recursive:=True)
'Insert new menuitem (button)
Set NewMenuItem = RowMenu.Controls.Add(Type:=msoControlButton)
With NewMenuItem
.Caption = "Postmodtager (som vedhæftet PDF)..."
.FaceId = 5622
.OnAction = "SendPDFSomMail"
End With
End Sub
' Code for putting the item in the menu
Private Sub Workbook_Open()
MyNewMenu HideMe
InsertMenuItem
End Sub
I know I have to put the code to delete it in an Workbook_BeforeClose
sub but cannot get anything to work. All examples i find is to delete
an entire menu and not a single menu item.
Any ideas?
To menu (ie in at submenu to the files menu).
The macro is set in the ThisWorkbook section but i cannot figure out
how to delete it again (i get multiple items of it).
The code looks like this:
' Code for creating the menu item
Sub InsertMenuItem()
Dim RowMenu As CommandBarControl
Dim NewMenuItem As CommandBarButton
'Find menuitem Row
Set RowMenu = CommandBars(1).FindControl(ID:=30095,
recursive:=True)
'Insert new menuitem (button)
Set NewMenuItem = RowMenu.Controls.Add(Type:=msoControlButton)
With NewMenuItem
.Caption = "Postmodtager (som vedhæftet PDF)..."
.FaceId = 5622
.OnAction = "SendPDFSomMail"
End With
End Sub
' Code for putting the item in the menu
Private Sub Workbook_Open()
MyNewMenu HideMe
InsertMenuItem
End Sub
I know I have to put the code to delete it in an Workbook_BeforeClose
sub but cannot get anything to work. All examples i find is to delete
an entire menu and not a single menu item.
Any ideas?