Several people asked me how to remove the word "Invitation:" from the subject of Gmail invitations, as it takes up a lot of space on Outlook's calendar, making it difficult to see the appointment subject.
How can I remove the word 'Invitation' from every appointment that originated as an invite from a Google calendar?
After installing the macro, new and updated meeting subjects will have "Invitation:" and "Updated invitation:" removed from the subject.
Option Explicit Private objNS As Outlook.NameSpace Private WithEvents objItems As Outlook.Items Private Sub Application_Startup() Dim objWatchFolder As Outlook.Folder Set objNS = Application.GetNamespace("MAPI") 'Set the folder and items to watch: Set objWatchFolder = objNS.GetDefaultFolder(olFolderCalendar) Set objItems = objWatchFolder.Items Set objWatchFolder = Nothing End Sub Private Sub objItems_ItemAdd(ByVal Item As Object) Dim strTemp As String 'Debug.Print Item.Subject strTemp = LCase(Item.Subject) If InStr(LCase(Item.Subject), "invitation: ") > 0 Then strTemp = Replace(strTemp, "Invitation: ", "") 'Debug.Print strTemp Item.Subject = strTemp Item.Save End If End Sub Private Sub objItems_ItemChange(ByVal Item As Object) Dim strTemp As String 'Debug.Print Item.Subject, "change" If InStr(Item.Subject, "invitation: ") > 0 Then strTemp = Replace(Item.Subject, "Updated invitation: ", "") 'Debug.Print strTemp Item.Subject = strTemp Item.Save End If End Sub
Remove Prefix from Existing Appointments
To remove Invitation from existing appointments, we'll use a version of the macro at Copy: is prefixed to the Subject of a Meeting.
Put this macro in a module, select the calendar the Gmail invitations are on then run the macro. It will remove Invitation: and Updated invitation from the meeting subjects.
Sub FixExistingAppts() Dim myolApp As Outlook.Application Dim calendar As MAPIFolder Dim Item As Object Set myolApp = CreateObject("Outlook.Application") Set calendar = myolApp.ActiveExplorer.CurrentFolder Dim iItemsUpdated As Integer Dim strTemp As String iItemsUpdated = 0 For Each Item In calendar.Items If InStr(1, LCase(Item.Subject), "invitation: ") > 0 Then strTemp = Replace(Item.Subject, "Updated invitation: ", "") strTemp = Replace(strTemp, "Invitation: ", "") Item.Subject = strTemp iItemsUpdated = iItemsUpdated + 1 Item.Save End If Next Item MsgBox iItemsUpdated & " of " & calendar.Items.Count & " Meetings Updated" End Sub
How to use the macros on this page
First: You need to have macro security set to the lowest setting, Enable all macros during testing. The macros will not work with the top two options that disable all macros or unsigned macros. You could choose the option Notification for all macros, then accept it each time you restart Outlook, however, because it's somewhat hard to sneak macros into Outlook (unlike in Word and Excel), allowing all macros is safe, especially during the testing phase. You can sign the macro when it is finished and change the macro security to notify.
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, look at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Macros that run when Outlook starts or automatically need to be in ThisOutlookSession, all other macros should be put in a module, but most will also work if placed in ThisOutlookSession. (It's generally recommended to keep only the automatic macros in ThisOutlookSession and use modules for all other macros.) The instructions are below.
The macros on this page need to go into ThisOutlookSession (unless otherwise marked).
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the macro code in ThisOutlookSession:
- Expand Project1 and double click on ThisOutlookSession.
- Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)
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