Can't insert mailing address w/out country

G

Guest

When I insert an address from the Contacts list, how do I get it to leave out
the 'Country' field? Right now, whenever I write a letter, I have to go back
and delete "United States" from the address
 
G

Graham Mayor

See the use of macrobutton fields to insert addresses from Outlook
http://www.gmayor.com/Macrobutton.htm and substitute the following code for
that produced there.

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

'Set up the formatting codes in strCode
strCode = "<PR_DISPLAY_NAME>" & vbCr
strCode = strCode & "<PR_COMPANY_NAME>" & vbCr
strCode = strCode & "<PR_STREET ADDRESS>" & vbCr
strCode = strCode & "<PR_LOCALITY>, <PR_STATE_OR_PROVINCE>" _
< PR_POSTAL_CODE > " & vbCr"
strCode = strCode & "<PR COUNTRY>" & vbCr

'Let the user choose the name in Outlook
strAddress = Application.GetAddress _
("", strCode, False, 1, , , True, True)
'Strip away the final "United States of America", if any
If Right(strAddress, 25) = "United States of America" & vbCr Then
strAddress = Left(strAddress, Len(strAddress) - 25)
End If

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

'Insert the modified address at the current insertion point
Selection.TypeText strAddress
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Also try the following:

Copy the following exactly and save as an autotext entry called
AddressLayout (all one word)

{<PR_GIVEN_NAME> <PR_SURNAME>
}{<PR_COMPANY_NAME>
}{<PR_POSTAL_ADDRESS>}

(note the curly brackets are not field boundaries, but are typed from the
keyboard)

The variety of fields you can use in this manner are listed in the m
acrobutton article in my other post.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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