Address Retrieval Macro

R

Rob F

Below is a macro I use to insert addresses directly from
my Outlook address book into a Word document (the macro is
in Word). It's not a macro I wrote myself, I hasten to add!

My only niggle is that when the address book dialog opens
it opens with our networked Global Address Book active. I
would prefer it to open with my "personal" Outlook Address
Book Contact list active.

Can anyone suggest a tweak to the macro to do this?

Cheers

Rob F

******

Public Sub InsertAddressFromOutlook()
Dim strCode As String, strAddress As String
Dim iDoubleCR As Integer

'Set up the formatting codes in strCode
strCode = "<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr & _
"<PR_TITLE>" & vbCr & _
"<PR_COMPANY_NAME>" & vbCr & _
"<PR_POSTAL_ADDRESS>" & vbCr

'Display the 'Select Name' dialog, which lets the user
choose
'a name from their Outlook address book
strAddress = Application.GetAddress
(AddressProperties:=strCode, _
UseAutoText:=False, DisplaySelectDialog:=1, _
RecentAddressesChoice:=True,
UpdateRecentAddresses:=True)
'If user cancelled out of 'Select Name' dialog, quit
If strAddress = "" Then Exit Sub

'Eliminate blank paragraphs by looking for two
carriage returns in a row
iDoubleCR = InStr(strAddress, vbCr & vbCr)
Do While iDoubleCR <> 0
strAddress = Left(strAddress, iDoubleCR - 1) & _
Mid(strAddress, iDoubleCR + 1)
iDoubleCR = InStr(strAddress, vbCr & vbCr)
Loop

'Strip off final paragraph mark
strAddress = Left(strAddress, Len(strAddress) - 1)
'Insert the modified address at the current insertion
point
Selection.Range.Text = strAddress

End Sub
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Rob,

The GetAddress method Returns an address from the default address book. I
think that changing the default address book is probably more of an Outlook
issue rather than a Word issue. As a result, you may be more likely to get
the information that you need if you post to one of the Outlook newsgroups.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
T

Thomas Winter

This MIGHT help:

1. In Microsoft Outlook, select the Tools menu.
2. Select the Services menu item.
3. In the Services window, click the Addressing tab.
4. From the Show this address list first drop-down, select your contacts
folder. Make sure you select an appropriate line UNDER Outlook Address Book.
Contacts is usually your main contacts folder in Outlook.
5. Click OK.

Using CDO (Collaboration Data Objects) may give you some more options, but
its (relatively) more complicated. Doug is correct, this is more of an
Outlook issue and the Outlook newsgroups might be the better place to ask
about this (and CDO if you want!)

-Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top