This macro shows how to remove a signature from a message using VBA when you are composing a message. While this macro won't save a lot of time as it's almost as easy just to select and delete it, you can add it to macros that do other things. Because it uses the ActiveInspector, it will work best with macros that automate replying, such as "VBA Sample: Do Something When Reply is Clicked".
Sub RemoveSignature() Dim Item As Outlook.MailItem Set Item = Application.ActiveInspector.CurrentItem Dim objDoc As Word.Document Dim oBookmark As Word.Bookmark On Error Resume Next Set objDoc = Item.GetInspector.WordEditor Set oBookmark = objDoc.Bookmarks("_MailAutoSig") If Not oBookmark Is Nothing Then oBookmark.Select objDoc.Windows(1).Selection.Delete End If Set Item = Nothing End Sub
If you use this macro in a run a script rule, you'll need to use .Display to show the inspector and will see a flash on the screen as the message is opened, the signature removed, and then sent.
Tip: if you don't want to use a signature when a macro creates a new message, you can use item.body = "" or copy the body from a message to send without a signature.
Sub ReplywithNote() Dim Item As Outlook.MailItem Set Item = Application.ActiveExplorer.Selection.Item(1) Dim olInspector As Outlook.Inspector Dim olDocument As Word.Document Dim olSelection As Word.Selection Set myReply = Item.Reply myReply.Display Set olInspector = myReply.GetInspector Set olDocument = olInspector.WordEditor Set olSelection = olDocument.Application.Selection olSelection.InsertBefore "This is my note" Set oBookmark = olDocument.Bookmarks("_MailAutoSig") If Not oBookmark Is Nothing Then oBookmark.Select olDocument.Windows(1).Selection.Delete End If ' uncomment to send 'myReply.Send End Sub
Macro samples to insert signatures are available at
How to use the Macro
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security. If Outlook tells you it needs to be restarted, close and reopen Outlook. Note: after you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Now open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor.