Is there any way that I can remove the Print item from the context menu when you right-click on an email with VBA?
I am forever right-clicking to reply to an email, only to accidentally click Print
and have Outlook send it directly to the printer quicker than I can stop it.
NB: I am using Outlook 2007.
Via File-> Options-> Customize Ribbon, you can remove the Actions group from the Attachments tab and add a new group of your own. You can then add the commands that you want to have available to you. This allows you to recreate the default Actions group but then without the Quick Print button.
Based on the link TcKs provide, that was pretty simple. In the example below I check the type of the item so that it only affects e-mails and not calendar items. To enter the code in outlook, Type Alt + F11, then expand the Microsoft Office Outlook Objects in the Project pane. Then double click the ThisOutlookSession. Then paste this code into the code window. I don't like to check captions like this as you can run into issues with internationalization. But I didn't see an ActionID or anything on the Command. There was a FaceID but that is just the id of the printer icon.
Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Selection)
Dim cmdTemp As Office.CommandBarControl
If Selection.Count > 0 Then
Select Case TypeName(Selection.Item(1))
Case "MailItem"
For Each cmdTemp In CommandBar.Controls
If cmdTemp.Caption = "&Print" Then
cmdTemp.Delete
Exit For
End If
Next cmdTemp
Case Else
'Debug.Print TypeName(Selection.Item(1))
End Select
End If
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With