Blog Post

Exchange Team Blog
2 MIN READ

Synching Office locations on to your Smartphone

The_Exchange_Team's avatar
May 03, 2004

If you’re a proud Smartphone owner, you might have noticed that the ‘Office Location’ field doesn’t get synched onto the device when it’s part of your Contact entries. For some, maybe not a big deal, but in the Microsoft GAL we have everyone’s office number populated in that field, and when I’m wandering the halls of building 34 it sure is handy to remember the office number of the people I’m going to see. Anyway, you know if you pull up the GAL and look in someone’s details, there’s an ‘Add to Contacts’ button…? Well, as I’ve added lots of Redmond-ites to my OL contacts, I hacked up a little bit of VB that will populate the ‘Street address’ line (if blank, which it generally is for internal, GAL-derived contacts) with the contents of the OfficeLocation field, and that means when you view the contact on the Smartphone, the office number shows up on the main display as “Office Address”.

To install, just go Tools -> Macro -> Macros, type any old name for the new macro and hit the Create button.

When presented with the VB window, select the existing code snippet and paste the following in

Sub populate_address()
    Dim oFld As MAPIFolder
    Dim oItems As items
    Dim oItem As ContactItem

    Set oFld = ThisOutlookSession.ActiveExplorer.CurrentFolder
    If oFld.DefaultMessageClass <> "IPM.Contact" Then
        Set oFld = ThisOutlookSession.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
    End If

    Set oItems = oFld.items
    totalmods = 0

    For i = 1 To oItems.Count
        Set oItem = oItems(i)
        If oItem.OfficeLocation <> "" And _
            oItem.BusinessAddressStreet = "" Then
                oItem.BusinessAddressStreet = oItem.OfficeLocation
                totalmods = totalmods + 1
                oItem.Save
        End If
    Next

    MsgBox "Modified " & totalmods & " out of a total of " & oItems.Count, vbOKOnly + vbInformation, "Contact Addresses updated"

    Set oItem = Nothing
    Set oItems = Nothing
 
   Set oFld = Nothing
End Sub

Then go File -> Close & Return to Microsoft Outlook. Now, to run the Macro, you just need to go Tools -> Macro -> Macros, select it and Run. It’ll figure out your default contacts folder if you’re not currently pointing at it, and although there isn’t much of a UI, it’s not something you’d need to run very often.

- Ewan Dalton

Updated Jul 01, 2019
Version 2.0
No CommentsBe the first to comment