Select Outlook Contacts in Word Form

J

Jean

I have a form that I have designed for a quote, entering
sold to and ship to name and address in form fields. What
I want to be able to do is select the names and addresses
from the outlook contacts? Is this possible and if so how?
Thanks!
 
K

Kerry Hewett

Hi Jean

I am just going through the same thing. This code is
working wonderfully. I have this code attached to a
button on my user form. Happy Programming.

Kerry
__________________________

Sub ChooseRecipient()
'using the field names receeded by pr_ decide which fields
from outlook you wish to insert

StrCodeR = "<pr_given_name> <pr_surname>" & vbCr
& "<pr_company_name>" & vbCr & "<pr_postal_address>"

'display the selct names dialogue box
StrAddressR = Application.GetAddress
(addressproperties:=StrCodeR, useautotext:=False,
displayselectdialog:=1, recentaddresseschoice:=True,
updaterecentaddresses:=True)

'if user cancels out of select names dialogue box
If StrAddressR = "" Then Exit Sub

'eliminate blank paragraphs by looking for 2 carriage
returns in a row
idoubleCRr = InStr(StrAddressR, vbCr & vbCr)
Do While idoubleCR <> 0
StrAddressR = Left(StrAddressR, idoubleCRr - 1) & _
Mid(StrAddressR, idoubleCRr + 1)
idoubleCRr = InStr(StrAddressR, vbCr & vbCr)
Loop

'strip off final paragraph mark
StrAddressR = Left(StrAddressR, Len(StrAddressR) - 1)
 
G

Guest

I really appreciate this code, I am a very new user of VB.
I cannot get the following section of code to compile:
(addressproperties:=StrCodeR, useautotext:=False,
displayselectdialog:=1, recentaddresseschoice:=True,
updaterecentaddresses:=True) I get the following error:
Expected: line number of label or statement or end of
statement
Thanks!
 
K

Kerry

Hi Jean
It wasn't terribly clear when i pasted the code into the
message

thie code should be entered as one command line starting
with
straddressr=..................updaterecentaddresses:=True)

hope this helps
 
G

Guest

I've got the list of contacts displaying ok, but once I
select one it does not appear in my document.
 

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