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
I can't get this to work yet... my user is with exchange office 365 and outlook version 1912.
is there a way to fix this on the google side ? I run the macro it says 0 or 1435 calendar events fixed.
No sorry, this is how google does it and it can't be changed.
Would it be possible to create a second set of macros that removes the end of the Google title (e.g." @ Fri Nov 8, 2018.....").
Seems like you could use the " @ Fri " to find the start of the text (and duplicate for each day of the week. However, I don't understand wildcards enough to know how to take out everything after that point. Or maybe you could do a "left function" to only keep the characters that come before that point?
The easiest would be to find the position of the @ and keep everything to the left - add it after the replace lines:
strTemp = Replace(strTemp, "Invitation: ", "")
lenAt = InStr(1,strTemp, "@")
strtemp = left(strtemp, lenAt)
This leaves the @ though... what's the best way to modify the code to fix that?
You can do math in the length calculation -
lenAt = InStr(1,strTemp, "@") - 1
I didn't have a problem loading the macro to fix existing events...it works great. I also copied/pasted the macro to update new events, but nothing happens when new events arrive. They still have the prefix. Any idea what I'm doing wrong?
Did you put it in ThisOutlookSession and restart Outlook?
I did but the macro still doesn't run automatically. I also noticed the macro to fix existing events only affects the ones that start with Invitation and not the ones that start with Updated Invitation.
The first set of macros - that contain the 'Private Sub objItems_ItemAdd' macro are automatic. The second set are not - they fix current items.
Unless google changes the prefixes, they should both do new and updated invitations.
As an FYI, if you use an Exchange mailbox, the changes may not stick. It's not longer possible to edit appointment subjects on the mac side and may eventually make it to the windows side.
Yeah, I understand how they should be working...but they're not. I am getting new invitations with the prefix Invitation: and the automatic macro is not fixing it. I also have events on my calendar that have the prefix Updated invitation: that aren't getting fixed when I run the manual macro.
I'm not using an Exchange mailbox.
Can this be done at a tenant level in Office 365 or does it need to be on an individual basis?
It needs to be done on each individual computer.