Anda di halaman 1dari 7

OUTLOOKUSERS EXCHANGEADMIN DEVELOPER OUTLOOKBCM OUTLOOK2011 COMMONPROBLEMS UTILITIES EMOARCHIVES

Search
WHAT'S NEW RSS
Map Contact Addresses or Meeting Locations
Microsoft

Translator
Subscribe to EMO
Subscribe to our
weekly newsletter
Subscribe
Latest Issue: Volume 19 Issue 25
Training and assistance
Do you need help setting up
Outlook, moving your email to a new
computer, or just need some one-
on-one help? I'm available for hire.
See Training and one-on-one
assistance for fees and to check
availability.
Looking for an Outlook Developer?
Outlook & Exchange Developers
OUR SPONSORS
Translate this page
Spanish
Do you have a Question?
Visit our forum.
Home / Developer / Map Contact Addresses or Meeting Locations
Last reviewed on August 1, 2014
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.
VBA Basics
How to use the VBA Editor
Work with open item or
selected item
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
Outlook-tips.net Samples
VBOffice.net samples
OutlookCode.com
SlovakTech.com
converted by Web2PDFConvert.com
Newest VBA Samples
Working with All Items in a
Folder or Selected Items
Use a macro to create a rule to
move messages
Create Birthday Events for Public
Folder Contacts
Automatically Add a Category to
Accepted Meetings
Remove an Address from Reply
All
Run all Outlook Rules on Startup
Combine and Print Multiple
Outlook Calendars
Save and Rename Outlook Email
Attachments
Create a custom printout in
Outlook
Mail Merge to Contact Groups
The Short URL for this page is
http://slipstick.me/stq-1
For google maps, use this url:
CompanionLink: Your Data on Your Device.
Contacts. Calendar. Tasks. Memos. Android, BlackBerry, Apple, Windows Phone.
Sync Google Calendar, Contacts, and Tasks with Outlook.
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 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 = "http://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
strURL = "https://maps.google.com/maps?
f=q&source=s_q&hl=en&geocode=&q=" & strAddress
Outlook MVP David Lee
MSDN Outlook Dev Forum
Microsoft Outlook
How to
Convert to / from
Outlook
Converting Messages
and Calendar or
Address books
Moving Outlook to a New
Computer
Moving Outlook 2010 to a
new Windows computer
Moving from Outlook
Express to Outlook
Repair PST
Repair damaged PST file
Repair large PST File
Remove password - *.PST
Convert *.OST to *.PST
Recover Deleted Items
Recover deleted messages
from .pst files
Are Deleted Items gone
forever in Outlook?
POPULAR COMMENTS LATEST
WEEK MONTH ALL
Using Google
Calendar Sync Utility
with Outlook
Sync calendar and
contacts using
Outlook.com
This operation has
been cancelled due to
restrictions in effect
Messages are stuck in
the Outbox
Convert an Offline File
(.ost) to a Personal
File (.pst)
Configure Gmail
Accounts in Outlook
Moving Outlook to a
New Computer
Moving Outlook to a
new Windows
computer
Pictures don't display
in Outlook messages
Remove a password
from an Outlook *.pst
File
converted by Web2PDFConvert.com

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+z
ip.
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/st
reet+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.
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
converted by Web2PDFConvert.com
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.
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
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
Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" &
" " & strURL), vbNormalFocus
converted by Web2PDFConvert.com
Twitter 2 Facebook 2 Google LinkedIn Tumblr Reddit Email
Print More
Diane Poremsky
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.
More Information
Easily Link to Locations and Directions Using the New Google Maps
Google+
Related Posts:
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 = "http://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
Sub cmdMap_click()
Set oApp = CreateObject("InternetExplorer.Application")
strAddress = item.BusinessAddressStreet & "+" &
item.BusinessAddressCity & "+" & item.BusinessAddressState
strAddress = Replace(strAddress, " ", "+")
strURL = "https://maps.google.com/maps?
f=q&source=s_q&hl=en&geocode=&q=" & strAddress
oApp.navigate (strURL)
oApp.Visible = True
End Sub



Follow 306
converted by Web2PDFConvert.com
Written by 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.
Please post long or more complicated questions at Outlookforums.
4 responses to Map Contact Addresses or Meeting Locations
Leave a Reply
Enter your comment here...
Kiran March 14, 2014 at 12:47 pm | Permalink | Reply
Thanks, Really this code is very useful for me.
I need to put all my contact on one google map.
What can I do??
Diane Poremsky March 14, 2014 at 3:27 pm | Permalink | Reply
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.
Haik April 7, 2014 at 5:47 pm | Permalink | Reply
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?
Diane Poremsky April 8, 2014 at 3:37 pm | Permalink | Reply
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.
converted by Web2PDFConvert.com
Contact Tools
Data Entry and Updating
Duplicate Checkers
Phone Number Updates
Online Services
Contact Management Tools
Mail Tools
Sending and Retrieval Tools
Mass Mail Tools
Compose Tools
Duplicate Remover Tools
Mail Tools for Outlook
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
Sync & Share
Share Calendar & Contacts
Synchronize two machines
Sharing Calendar and
Contacts over the Internet
More Tools and Utilities for
Sharing Outlook Data
Access Folders in Other
Users Mailboxes
View Shared Subfolders in
an Exchange Mailbox
"Live" Group Calendar
Tools
Search
Home | OutlookUser | Exchange Administrator | Common Problems | About Slipstick | Advertise
Submit New or Updated Outlookand Exchange Server Utilities
Send comments using our Feedback page
Copyright 2014 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.
Back to Top
Previous Next
If the Post Coment button disappears, pressyour Tab key.
converted by Web2PDFConvert.com

Anda mungkin juga menyukai