In Outlook 2013, when you open the Contact form, you’ll find that the Activities tab has been removed from the Show group on the Ribbon. While much of its use has been replaced by other functionality such as Instant Search and the People Pane (Social Connector), on occasion, you might still have a need to find all Outlook items related to a specific contact and have that available directly from the contact itself.
As the Contact Activities view basically isn’t much more than an elaborate search, we can revive this feature via some VBA code. This guide contains the code and instructions on how to implement, use and extend such a programmatic search.
Background info:
The actual removal process already started a few versions back when sub-functionality of Contact Activities had already been disabled or removed. For instance, Automatic Journaling has been removed in Outlook 2007, the Contact Linking field has been disabled by default since Outlook 2007 (and removed in Outlook 2013) and defining your own Contact Activities folder groups is no longer possible since Outlook 2010.
FindContactActivities VBA macro
The FindContactActivities macro uses Outlook’s built-in Instant Search functionality to find all items which are related to the current open contact form. These search results are presented in a separate Outlook window so you can directly interact with these items.
The search in the macro is being done based on the To, From and Linked Contacts field and uses the full name and email addresses of the current open contact as the search value.
In the Code modifications section, it is shown how you can include other fields as well and to search for recent items only.
Note:
As this macro relies on Windows Search, having a properly functioning Search Index is required. This also means that when you are using an Exchange account, you must have it configured in Cached Exchange Mode (which is the default).
Quick Install
Use the following instructions to configure the macro in Outlook;
- Download this code-file (
findcontactactivities.zip
) or copy the code below. - Open the VBA Editor (keyboard shortcut ALT+F11)
- Extract the zip-file and import the
FindContactActivities.bas
file via File-> Import…
If you copied the code, paste it into a new module. - Add a button for easy access to the macro.
- Sign your code.
Add a button to your QAT or Ribbon to quickly execute the Activities search.
Macro code
The following code is contained in the zip-file referenced in the Quick Install. You can use the code below for review or manual installation.
Click in the area above and press CTR+A to select all. Press CTRL+C to copy the code.
Code modifications and searching other fields
Below are some examples of how you can include additional fields in your search or how to set a timeframe to search in. You can add these lines after the final olkFilter line but must be added before the Call olkExplorer line.
Finding items which have been modified (which also includes sent, received or created) this year:
olkFilter = olkFilter & " AND " & "modified:thisyear"
Finding items which have been modified since a specific date (note that the date notation must match your date notation as configured in Windows):
olkFilter = olkFilter & " AND " & "modified:=>1/1/2012"
To also include items which has been sent to or received from a contact’s second address:
Dim myContactAddress2
myContactAddress2 = myContact.Email2Address
olkFilter = olkFilter & " OR " & "to:" & Chr(34) & myContactAddress2 & Chr(34) & _
" OR " & "from:" & Chr(34) & myContactAddress2 & Chr(34)
To only return specific item types such as Tasks, Meetings, Appointments or Notes (sticky):
(for an overview of message class names see: Item Types and Message Classes)
olkfilter = olkfilter & " AND " & "messageclass:" & Chr(34) & "ipm.task" & Chr(34)
The “Linked Contacts” field has been removed in Outlook 2013 and can only be re-enabled via a Registry key (old items will still maintain their Linked Contacts if specified even without the Registry modification). As it could still be completely removed in later versions, you can also choose to type the names of related contacts in the Notes section of an item such as a Task. To prevent items from showing up where the contacts are only mention in, you could prefix your line with for instance “Related contacts:”. You’d then extend the search in the following way:
olkFilter = olkFilter & " OR " & "contents:(" & Chr(34) & "related contacts" & _
Chr(34) & " AND " & Chr(34) & myContactName & Chr(34) & ")"
For an overview of other possible fields to search for and other refinements see the guide;
Instant Search query commands reference