Outlook 365 Searching all shared calendars

Not open for further replies.


New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
I understand from my research that outlook will not search shared calendars. It will only search for an appointment etc with the current folder.

I have a scenario where I have 3 engineers who have appointments and a client rings up and says "I believe I have made an appointment my address is....., can you check please."

Under the current system I have to do a postcode search in each engineers calendar to see if an appointment has been made. This is time consuming and we are soon going to have 5 engineers.

Is there a way that you can create a macro that will run a search in each shared calendar automatically and produce reports?


Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This is probably messy code (since I put several macros together) but it should work - and might need tweaked a bit more. It asks for a keyword to search for then searches for recent appointments containing that word in the body or subject.

Like the print calendar I used as the base, you need to select calendar you want to search. if it finds a match on a calendar, a dialog box says which calendar then go to the next calendar.

 Dim CalFolder As Outlook.Folder
 Dim nameFolder
Dim strKeyword
 ' Run this macro
 Sub SearchinSharedCalendars()
 Dim objPane As Outlook.NavigationPane
 Dim objModule As Outlook.CalendarModule
 Dim objGroup As Outlook.NavigationGroup
 Dim objNavFolder As Outlook.NavigationFolder
 Dim objCalendar As Folder
 Dim objFolder As Folder

 Dim i As Integer
 Dim g As Integer

 On Error Resume Next

 Set objCalendar = Session.GetDefaultFolder(olFolderCalendar)

 Set Application.ActiveExplorer.CurrentFolder = objCalendar
strKeyword = InputBox("Search subject and body for", "Search Shard Calendars")

 Set objPane = Application.ActiveExplorer.NavigationPane
 Set objModule = objPane.Modules.GetNavigationModule(olModuleCalendar)

 With objModule.NavigationGroups

 For g = 1 To .Count

 Set objGroup = .Item(g)

 For i = 1 To objGroup.NavigationFolders.Count
 Set objNavFolder = objGroup.NavigationFolders.Item(i)

 If objNavFolder.IsSelected = True Then

 'run macro to copy appt
 Set CalFolder = objNavFolder.Folder
 Set nameFolder = objNavFolder

 Dim NS As Outlook.NameSpace
 Dim objOwner As Outlook.Recipient
 Set NS = Application.GetNamespace("MAPI")
 Set objOwner = NS.CreateRecipient(nameFolder)
 If objOwner.Resolved Then
 Set CalFolder = NS.GetSharedDefaultFolder(objOwner, olFolderCalendar)
 End If


 End If
 Next i
 Next g
 End With

 Set objPane = Nothing
 Set objModule = Nothing
 Set objGroup = Nothing
 Set objNavFolder = Nothing
 Set objCalendar = Nothing
 Set objFolder = Nothing
 End Sub

 Private Sub SearchSharedCalendar()

 Dim CalItems As Outlook.Items
 Dim ResItems As Outlook.Items
 Dim sFilter As String
 Dim iNumRestricted As Integer
 Dim itm, newAppt As Object
Dim oFinalItems As Outlook.Items

 Set CalItems = CalFolder.Items

 If CalFolder = printCal Then
 Exit Sub
 End If

 ' Sort all of the appointments based on the start time
 CalItems.Sort "[Start]"
 CalItems.IncludeRecurrences = True

 On Error Resume Next
 strName = CalFolder.Parent.Name

' searches next 10 days
sFilter = "[Start] >= '" & Date & "'" & " And [Start] < '" & Date + 10 & "'"
Debug.Print sFilter

  'Restrict the Items collection for the 30-day date range
 Set ResItems = CalItems.Restrict(sFilter)
    'Construct filter for Subject containing strKeyword '0x0037001E
    Const PropTag  As String = "http://schemas.microsoft.com/mapi/proptag/"
    sFilter = "@SQL=" & Chr(34) & PropTag _
        & "0x0037001E" & Chr(34) & " like '%" & strKeyword & "%' OR " & Chr(34) & PropTag _
        & "0x1000001f" & Chr(34) & " like '%" & strKeyword & "%'"
Debug.Print sFilter
'Restrict the last set of filtered items for the subject
Set oFinalItems = ResItems.Restrict(sFilter)

'Sort and print final results
oFinalItems.Sort "[Start]"
 iNumRestricted = 0
For Each oAppt In oFinalItems
 iNumRestricted = iNumRestricted + 1
    Debug.Print oAppt.Start, oAppt.Subject, strName
 If iNumRestricted > 0 Then
 MsgBox iNumRestricted & " Matching Appointment found in " & strName
 End If
 Set itm = Nothing
 Set newAppt = Nothing
 Set ResItems = Nothing
 Set CalItems = Nothing
 Set CalFolder = Nothing

 End Sub

Tim Nollan

New Member
Outlook version
Outlook 2016 for Mac
Email Account
Outlook.com (as MS Exchange)
It should be interesting to be able to search in different shared calendars in Outlook 2016. It could be useful for schools and educational centers that need to find the same event (named in the same way, normally by the name of the student) in different calendars.
I use it in my work essayedge review very often
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
HarvMan Toggle between calendar and email in Outlook 365 Using Outlook 12
S Mac Outlook 365 Questions Using Outlook 1
R Outlook 365 update sets delete from server flag Using Outlook 1
O Outlook 365 - How to create / copy a new contact from an existing one? Using Outlook 3
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
F Outlook 365 is "Possessed" Using Outlook 2
K Outlook Office 365 VBA download attachment Outlook VBA and Custom Forms 2
AmonRa Outlook 365 calendar - too much white space Using Outlook 0
G Outlook 365 with iCloud account not syncing calendars Using Outlook 2
L Ideas for Setup with New Office 365 Family Subscription (Outlook) Using Outlook.com accounts in Outlook 3
D Connecting Gmail to Outlook 365 - My Setup not working Using Outlook 2
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
D Outlook 2016 how to use gmail account as source account for outlook 365 Using Outlook 9
M outlook 365 trying to finish my sentences Using Outlook 2
C Not sync folders not found after MS Outlook 365 update Using Outlook 1
D Outlook 2007 on 365 Using Outlook.com accounts in Outlook 2
Terry Sullivan Sender's Name Doesn't Appear in the From Field on Outlook 365/IMAP Using Outlook 2
A Backup Email Accounts On OutLook For Mac 2016 (Microsoft 365 subscription version) Using Outlook 0
X Using Outlook 2013 and Outlook 365 Using Outlook 1
D Sending email from Office 365 alias in Outlook Using Outlook 3
M Microsoft 365 Outlook keeps requesting password on Local Account Using Outlook 1
I Outlook 365 - import/attach PST file that used POP3 Using Outlook.com accounts in Outlook 0
HarvMan Outlook 365 PST Report Using Outlook 1
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
HarvMan Outlook 365 Calendar Using Outlook 13
L Outlook 2016 Contacts missing in Outlook 365 Using Outlook 1
J Edit auto-complete list in Outlook 2016+/365? Using Outlook 0
GregS Outlook 365 blocked by Google popup Using Outlook 2
O Synchronising contacts Outlook 365 with Google v.v. Using Outlook 4
David in Mississippi New (Feb 2020) install of Outlook 365 - Cannot specify PST for different accounts Using Outlook 0
O Outlook 365 Exchange .ost within Personal Vaul Using Outlook 0
D Outlook 2016 Deleting emails without affecting folder structure - Outlook Office 365 Using Outlook 3
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
H In outlook 365 POP mail Inbox, email takes a long time or never arrives. Using Outlook 1
B Outlook 365 - Folder pane list clears Using Outlook 28
J Copy to calendar function no longer working in outlook 365 Using Outlook 5
T Interim Outlook 365 Setup Using Outlook 2
T I'm thinking about moving from outlook.com to the Outlook I have in my Office 365 Using Outlook 1
M Outlook .com group does not show up in Outlook for office 365 home Using Outlook 3
Jennifer Murphy Outlook can't connect to Office 365 at resort hotel Using Outlook.com accounts in Outlook 1
DoctorJellybean Outlook 365 doesn't always mark emails as read Using Outlook 3
J Outlook Office 365 Win 10 how do I control background colors of events? Using Outlook 1
B Migrate Outlook 2007 to Office 365 Using Outlook 3
L Outlook Office 365 client: won't remember my setting File, not to collapse ribbon Using Outlook 2
G icloud pictures not showing in Outlook 365 Using Outlook 0
RBLampert Updating from Outlook 2010 to Outlook 365 Using Outlook 0
C Can't Open Outlook 365 Using Outlook 0
glnz How set up new IMAP on Outlook-Office 365 and merge in pst from Outlook 2003 for same two email accounts? Using Outlook 5
David Langer Outlook 2016 (365) How to restore the ability to Re-Map iCloud IMAP Folders Using Outlook 5
N Outlook 365 Email Notifications Using Outlook 0

Similar threads