Hi Graham,
This is certainly a strange one
FWIW, in the original example,
where the AddressLayout includes
{<PR_LOCALITY>}
(for City code) the content of field(s) on the last line in the AddressLayout don't appear in a document.
It doesn't seem to matter if it's the Email address or Cell phone # that's on the last row.
In your macro I noticed you used
{<PR_POSTAL_ADDRESS>}
When I substituted that for the line in the original of
{<PR_LOCALITY>}, {<PR_STATE_OR_PROVINCE>} {<PR_POSTAL_CODE>}
or just remove the {<PR_LOCALITY>}
field code then the content of the last field shows up.
It seems to be that particular field rather than a change in the # of fields in that case, but just to try a couple of variations,
if I cut and pasted the {<PR_COMPANY_NAME>} field to be the last line, the last line it stopped showing up again.
=====================
Further to my last:
Public Sub InsertAddressFromOutlookA()
Dim strTitle As String
Dim strJobTitle As String
Dim strForeName As String
Dim strSurname As String
Dim strCompany As String
Dim strAddress As String
Dim strCountry As String
Dim strPhone As String
Dim strFax As String
Dim strCell As String
Dim strEmail As String
Dim strFinal As String
'Set up the formatting codes in strCode
strTitle = "{<PR_DISPLAY_NAME_PREFIX> }"
strJobTitle = "<PR_TITLE>"
strForeName = "{<PR_GIVEN_NAME> }"
strSurname = "<PR_SURNAME>"
strCompany = "<PR_COMPANY_NAME>"
strAddress = "<PR_POSTAL_ADDRESS>"
strCountry = "<PR_COUNTRY>"
strPhone = "<PR_OFFICE_TELEPHONE_NUMBER>"
strFax = "<PR_BUSINESS_FAX_NUMBER>"
PstrCell = "<PR_CELLULAR_TELEPHONE_NUMBER>"
strEmail = "<PR_EMAIL_ADDRESS>"
'Let the user choose the name in Outlook
On Error GoTo UserCancelled:
strAddress = Application.GetAddress("", strAddress, _
False, 1, , , True, True)
If strAddress = "" Then
MsgBox "User cancelled or no address listed", , "Cancel"
Exit Sub
End If
strTitle = Application.GetAddress("", strTitle, _
False, 2, , , True, True)
strForeName = Application.GetAddress("", strForeName, _
False, 2, , , True, True)
strSurname = Application.GetAddress("", strSurname, _
False, 2, , , True, True)
strCompany = Application.GetAddress("", strCompany, _
False, 2, , , True, True)
strJobTitle = Application.GetAddress("", strJobTitle, _
False, 2, , , True, True)
strCountry = Application.GetAddress("", strCountry, _
False, 2, , , True, True)
strPhone = Application.GetAddress("", strPhone, _
False, 2, , , True, True)
strFax = Application.GetAddress("", strFax, _
False, 2, , , True, True)
strCell = Application.GetAddress("", strCell, _
False, 2, , , True, True)
strEmail = Application.GetAddress("", strEmail, _
False, 2, , , True, True)
strFinal = strTitle & Left(strForeName, 1) & " " & strSurname & vbCr
If strCompany <> "" Then
strFinal = strFinal & strCompany & vbCr
If strJobTitle <> "" Then
strFinal = strFinal = strFinal & strJobTitle & vbCr
End If
End If
If InStr(strCountry, "United States") Then
strAddress = Left(strAddress, Len(strAddress) - 25)
End If
With Selection ' type in the name string _
using the Inside Address paragraph style
.Style = ActiveDocument.Styles("Normal")
.TypeText Text:=strFinal
.TypeText Text:=strAddress
.TypeParagraph
If strPhone <> "" Then
.TypeText Text:="Phone: " & strPhone
.TypeParagraph
End If
If strFax <> "" Then
.TypeText Text:="Fax: " & strFax
.TypeParagraph
End If
If strCell <> "" Then
.TypeText Text:="Cell: " & strCell
.TypeParagraph
End If
If strEmail <> "" Then
.TypeText Text:="Email: " & strEmail
.TypeParagraph
End If
End With
UserCancelled:
End Sub
will insert the addresses more or less as you require them.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>