• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Map Contact Addresses or Meeting Locations

Slipstick Systems

› Developer › Map Contact Addresses or Meeting Locations

Last reviewed on June 28, 2019     9 Comments

Applies to: Outlook (classic), Outlook 2007, Outlook 2010

map directions for multiple contacts

While Outlook's MapIt button can be reprogrammed to use another map service, you'll need to use VBA if you want to use a second map service or map multiple addresses or locations at once.

Jerry wanted to use Zillow but he uses Outlook 2003 and Outlook 2003's map service can't be reprogrammed, so in the first example, I'm using Zillow. Although Zillow seems to accept anything Outlook throws at them (%20 for spaces, + as word separators, no separators), their default spacer is a dash, so I'm using a function to replace spaces in the address with a dash. It makes a prettier URL too. :)

I'm constructing the address from the individual address fields but you could simply use strAddress = oContact.BusinessAddress or strAddress = oContact.HomeAddress.

This macro may work in Outlook 2002 and Outlook 2000; however I did not test it in those versions. It was tested in Outlook 2003 and up.

Map an Address Macro

Press Alt+F11 to open the VBA editor and paste the code into ThisOutlookSession. Customize the toolbar, ribbon, or QAT, by adding the macro to a button in the main Outlook window. Select the Contact and run the macro.

Sub MapAddress()
  
  Dim strURL As String
  Dim oApp As Object
  Dim strAddress As String

  Set oApp = CreateObject("InternetExplorer.Application")

If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
 Set oContact = ActiveExplorer.Selection.Item(1)

strAddress = oContact.BusinessAddressStreet & "-" & oContact.BusinessAddressCity & "-" & oContact.BusinessAddressState

ReplaceSpaces strAddress
strURL = "https://www.zillow.com/homes/" & strAddress

oApp.navigate (strURL)
oApp.Visible = True

'wait for page to load before passing the web URL
Do While oApp.Busy
  DoEvents
Loop
 End If

Set oApp = Nothing
End Sub

Private Sub ReplaceSpaces(strAddress As String)
  strAddress = Replace(strAddress, " ", "-")
End Sub

For google maps, use this url:

strURL = "https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" & strAddress

Map a Meeting Location

Use this macro to map an address in a meeting or appointment's Location field.

This macro will work with either selected or opened appointments. You'll need the GetCurrentItem function to use it.

If you need to use a location in the appointment body, use regex to capture the address.

Sub MapLocation()
   
  Dim strURL As String
  Dim oApp As Object
  Dim strAddress As String

  Set oApp = CreateObject("InternetExplorer.Application")
 
 Set oAppt = GetCurrentItem()
 
strAddress = oAppt.Location
 
ReplaceSpaces strAddress
strURL = "https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" & strAddress
 
 
oApp.navigate (strURL)
oApp.Visible = True
 
'wait for page to load before passing the web URL
Do While oApp.Busy
  DoEvents
Loop

Set oApp = Nothing
End Sub
 

Private Sub ReplaceSpaces(strAddress As String)
  strAddress = Replace(strAddress, " ", "-")
End Sub

Add the maplink to the meeting body

This sample code shows how to add a link to the map to the body of a meeting (or appointment).

 Sub MapMeetingsLocation()
   
  Dim strURL As String
  Dim oApp As Object
  Dim strAddress As String

 
 Dim oAppt As AppointmentItem
 Set oAppt = Application.ActiveInspector.CurrentItem
 
strAddress = oAppt.Location
 
ReplaceSpaces strAddress
strURL = "https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" & strAddress
 
oAppt.Body = oAppt.Body & vbCrLf & strURL

Set oApp = Nothing
End Sub

 

Map Multiple Addresses or Locations

You can get directions to multiple addresses using Google Maps with a URL formatted like this: https://www.google.com/maps/dir/street+city+state+zip/street+city+state+zip.

Use Current+Location to begin at your location or add your address as the first string. https://www.google.com/maps/dir/Current+Location/street+city+state+zip/street+city+state+zip.

I'm using a select case statement so we can use one macro for both appointments/meetings and contacts. I'm also using an If Statement to get a home address if the business address doesn't exist.

To use, select the contacts in first stop to last order and run the macro. Appointment locations are mapped first appointment to last. It works with any calendar or contacts folder in your profile.

Public Sub MapMultipleAddresses()
 
Dim Session As Outlook.NameSpace
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim oItem As Object
Dim strURL As String
Dim oApp As Object
Dim strAddress As String

Set oApp = CreateObject("InternetExplorer.Application")
Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection

On Error Resume Next

For Each oItem In Selection

 
Select Case oItem.Class
 Case olContact
 If oItem.BusinessAddressCity = "" Then
 
 strAddress = strAddress & "/" & oItem.HomeAddressStreet & "+" & _
    oItem.HomeAddressCity & "+" & oItem.HomeAddressState
    
 Else
  strAddress = strAddress & "/" & oItem.BusinessAddressStreet & "+" & _
    oItem.BusinessAddressCity & "+" & oItem.BusinessAddressState

 End If

Case olAppointment, olMeeting
 strAddress = strAddress & "/" & oItem.Location
End Select

Err.Clear
Next

' replace spaces with +
strAddress = Replace(strAddress, " ", "+")

' use dir/Current+Location to start at your location
' or add your address to the url
strURL = "https://www.google.com/maps/dir" & strAddress

oApp.navigate (strURL)
oApp.Visible = True
 
'wait for page to load before passing the web URL
Do While oApp.Busy
    DoEvents
Loop

Set oApp = Nothing
Set Session = Nothing
Set currentExplorer = Nothing
Set oItem = Nothing
Set Selection = Nothing
End Sub

Using Firefox or Chrome Browser

If you want to use a different browser, you need to use the shell command to load the browser then pass the url to it. The shell command will look like this, with the full path to the browser. You need a space between the path to the browser and the url.

Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" & " " & strURL), vbNormalFocus

The path in my examples is for 64-bit Windows. If you use 32-bit Windows, the path will be C:\Program Files\Google\Chrome\Application\chrome.exe


Sub MapAddress()
  
  Dim strURL As String
  Dim strAddress As String

If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
 Set oContact = ActiveExplorer.Selection.Item(1)

strAddress = oContact.BusinessAddressStreet & "-" & oContact.BusinessAddressCity & "-" & oContact.BusinessAddressState

ReplaceSpaces strAddress
strURL = "//www.zillow.com/homes/" & strAddress

'Shell ("C:\Program Files (x86)\Mozilla Firefox\firefox.exe" & " " & strURL), vbNormalFocus
Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" & " " & strURL), vbNormalFocus

End If

End Sub

Private Sub ReplaceSpaces(strAddress As String)
  strAddress = Replace(strAddress, " ", "-")
End Sub

Create your own MapIt button in a custom form

To create your own MapIt button in a custom form, you need to remove a few lines of the code. This goes in the View Code window. Add a command button called cmdMap to call the script.

Sub cmdMap_click()
Set oApp = CreateObject("InternetExplorer.Application")
strAddress = item.BusinessAddressStreet & "+" & item.BusinessAddressCity & "+" & item.BusinessAddressState
strAddress = Replace(strAddress, " ", "+")
strURL = "//maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" & strAddress
oApp.navigate (strURL)
oApp.Visible = True
End Sub
   

To use Chrome use the following VBScript. Change the path to the browser to use FireFox or another browser.

Sub cmdMap_click()
Set Shell = CreateObject("WScript.Shell") 
strAddress = item.BusinessAddressStreet & "+" & item.BusinessAddressCity & "+" & item.BusinessAddressState
strAddress = Replace(strAddress, " ", "+")
strURL = "//maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" & strAddress
Shell.exec("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" & " " & strURL)
End Sub

To add buttons to map Home or Business address, use this code and two buttons, one called cmdMapBiz, and the other cmdMapHome.
custom form with map buttons

To create this form, I added pictures to labels (in the label's Advanced Properties) and renamed them cmdMapBiz and cmdMapHome. (I also added pictures to the email and web address labels.)

Dim strAddress 

Sub cmdMapBiz_click()
strAddress = item.BusinessAddressStreet & "+" & item.BusinessAddressCity & "+" & item.BusinessAddressState
strAddress = Replace(strAddress, " ", "+")
MapAddress 
End Sub

Sub cmdMapHome_click()
strAddress = item.HomeAddressStreet & "+" & item.HomeAddressCity & "+" & item.HomeAddressState
strAddress = Replace(strAddress, " ", "+")
MapAddress 
End Sub

Sub MapAddress()
Set Shell = CreateObject("WScript.Shell") 
strURL = "//maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" & strAddress
Shell.exec("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" & " " & strURL)
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 should be placed in a module.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More information as well as screenshots are at How to use the VBA Editor

Map Contact Addresses or Meeting Locations was last modified: June 28th, 2019 by Diane Poremsky

Related Posts:

  • Lookup a Contact's time zone
  • Open a Webpage when a Task Reminder Fires
  • View Messages in Internet Explorer using a macro
  • Open Hyperlinks in an Outlook Email Message

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
9 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Jim
January 30, 2020 2:16 pm

Hi, I've just started working on this project, to allow our Scheduling Coordinators to Map addresses of the Consultant's appointments as well as make a calendar entry above the appointment for Drive Time and Distance. The Consultant's home address is given as a recurring appointment at 07:00 each day, so it can be used as the "previous" appointment for the first call, and the previous appointments from there to the end of the day are used to map the drive times. I'm just diving in to this, and I'm already getting confused. If you're still looking at this page, Mrs. Poremsky, I hope I can ask you a question or two. Mainly, how would I get access to the Location of the previous appointment for the day? And is it possible to create that "Drive Time" entry automatically? If there's an easy way to have that Drive Time "appointment" include a link to Google Maps driving directions that would make it a truly beautiful thing. We use the "Maps for Outlook" add-in, but the developer has disappeared & later Updates to Windows and Outlook have rendered "Maps for Outlook" impossible to install or repair to a working state. Thank you… Read more »

0
0
Reply
RonH
October 28, 2016 7:54 pm

What if I only want the map with Stickpin and contact's name. Also, stuck trying to create a custom button. I am really inexperience at this stuff.

0
0
Reply
Diane Poremsky
Author
Reply to  RonH
October 29, 2016 12:37 am

the first & second macro should do just the stick pin. i'm not sure you can add the contact's name - that would be a feature of the map service. If they support adding a label, then it should be possible.

How to create buttons is at https://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/#button

0
0
Reply
Frank Scheidell
June 22, 2015 11:20 am

Thanks -- This helped out alot!

I have been working on this and was hoping to use the 'Address Selector' data field. I see it listed in fields that can be added to a label in the value tab of the control but it is not listed in the MSDN contact properties (see below).

MSDN ContactItem Properties

Is there a way to access this column in VBScript?

Also, I have added Custom Fields (ClientNumber). How do you access these custom columns?

ONE LAST question: There seem to be many differences between VBA and VBScript. Is this documented somewhere?

Thank you so much

Frank

0
0
Reply
Diana
October 13, 2014 11:37 pm

Thanks, this is really great.

0
0
Reply
Haik
April 7, 2014 5:47 pm

Hello Diane, I would like to have a macro in Outlook (when I make an appointment) which extracts the traveldistance (and driving time) from google maps.
How do I do that?

0
0
Reply
Diane Poremsky
Reply to  Haik
April 8, 2014 3:37 pm

You might need to use the google maps API. You can pass the address to google (from the location field) and get directions, but getting the values back would be the problem.

0
0
Reply
Kiran
March 14, 2014 12:47 pm

Thanks, Really this code is very useful for me.

I need to put all my contact on one google map.

What can I do??

0
0
Reply
Diane Poremsky
Reply to  Kiran
March 14, 2014 3:27 pm

Not using this code, but it should be possible if you have them in a CSV. That's how it was done in the past anyway. Looks like its still done that way - you can use either CSV or XLXS file format.

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 38

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • OUTLOOK.EXE continues running after you exit Outlook
  • How to Remove the Primary Account from Outlook
  • Reset the New Outlook Profile
  • How to Hide or Delete Outlook's Default Folders
  • Adjusting Outlook's Zoom Setting in Email
  • Disable "Always ask before opening" Dialog
  • Removing Suggested Accounts in New Outlook
  • Move an Outlook Personal Folders .pst File
  • Shared Mailboxes and the Default 'Send From' Account
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2026 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment