Outlook 365 Searching all shared calendars

Status
Not open for further replies.

mattfitzp

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?

Thanks
 

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.


Code:
 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
 DoEvents
 
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)
 objOwner.Resolve
 If objOwner.Resolved Then
 Set CalFolder = NS.GetSharedDefaultFolder(objOwner, olFolderCalendar)
 End If


SearchSharedCalendar

 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
Next
 
 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
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
X Using Outlook 2013 and Outlook 365 Using Outlook 1
D Sending email from Office 365 alias in Outlook Using Outlook 4
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 12
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 24
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
C Move Outlook 2007 to new PC with Outlook 365 Using Outlook 3
G Calendar View in Outlook Office 365 - Doesn't show enough hours, and the 30/60 min choice isn't the solution Using Outlook 4
O Outlook 365 - Toolbar - Close all items - missing? Using Outlook 3
O Outlook 365 - Tasks are not synchronizing? Using Outlook 7
W Migrating Outlook 365 Contacts & Calendar Using Outlook 2
O Outlook 365 ignores ForceOSTpath - how to relocate it? Using Outlook 9
O Office 365 Outlook - mark to download Using Outlook 0
M Indexing Problems Outlook 365 Using Outlook 2
P Insert link in email body to attached document in Outlook 365 Outlook VBA and Custom Forms 0
C Outlook 365 keeps closing Using Outlook 1
V Multiple Calendars in Outlook To-Do Bar; Office 365 Using Outlook 3
P Outlook 2016 Client and 365 - Groups Folder Using Outlook 3
B Outlook 365 Using Outlook 2
R How to delete Facebook Contacts folder in Outlook 365 Using Outlook 7
O Office 365 - Outlook - Password protect your mailbox Using Outlook 7
T Pick-a-Meeting in Outlook 365 New Slipstick.com Articles 2
Horsepower Office Outlook 365 home opens slower than a month ago Using Outlook 8
L Need to import multiple Outlook files to Office 365 Account Using Outlook 4
Similar threads


















































Top