Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pull Outlook info into Word UserForm

Status
Not open for further replies.

tcarroll5601

Technical User
Feb 19, 2009
6
US
I have a Word 2007 template that displays a userform upon opening. There are text boxes on the userform that they can fill in for the address of the receipient, or they can click a button to go to their Outlook Address Books to choose a receipient. I am struggling to find code to make this Outlook button function.

When they click the button on the user form, I need it to do the following:
1. Display a pop-up of their contacts (Application.GetAddress?)
2. Allow them to select a person from the list, and upon clicking 'OK', put the persons name, title, address, city, state and zip into the corresponding text boxes on the userform.

Please help, I am a beginner and I'm not sure where to start!
 
This is not actually trivial, and not really a beginner sort of project.

First of all, you need to ensure Security levels will even allow you do attempt this.


"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
As far as security is concerned...I have administrator permission to do this (pull from Outlook) and I am the manager of our Microsoft Word templates, and all of our users have their macro security set to 'Low'...so hopefully there is no issue.

Any insight as to where I should start with the code?

We used to have GroupWise (Novell) for our email, and this was the code that used to exist in our Word template to pull out contact info and populate it into the UserForm:

Private Sub CmdBtnGW_Click()
' Get an address from the GroupWise Address book
Dim varName$


' Assign the variables to the info pulled from the address book
' There are REM'd variables on the bottom for future additions

varName$ = WordBasic.GetAddress(, "<PR_GIVEN_NAME>", 0, 1, 0, , , 1)
txtName = WordBasic.[GetAddress$](, "<PR_GIVEN_NAME>" + " " + "<PR_SURNAME>", 0, 2)
TxtOwnersTitle = WordBasic.[GetAddress$](, "<PR_TITLE>", 0, 2)
txtAdd1 = WordBasic.[GetAddress$](, "<PR_STREET_ADDRESS>", 0, 2)
txtCity = WordBasic.[GetAddress$](, "<PR_LOCALITY>", 0, 2)
txtState = WordBasic.[GetAddress$](, "<PR_STATE_OR_PROVINCE>", 0, 2)
txtZIP = WordBasic.[GetAddress$](, "<PR_POSTAL_CODE>", 0, 2)
txtOrg = WordBasic.[GetAddress$](, "<PR_COMPANY_NAME>", 0, 2)
txtBusPhone = WordBasic.[GetAddress$](, "<PR_OFFICE_TELEPHONE_NUMBER>", 0, 2)
txtFax = WordBasic.[GetAddress$](, "<PR_PRIMARY_FAX_NUMBER>", 0, 2)
Rem phone$ = WordBasic.[GetAddress$](, "<PR_OFFICE_TELEPHONE_NUMBER>", 0, 2)
Rem phone$ = WordBasic.[GetAddress$](, "<PR_OFFICE_TELEPHONE_NUMBER>", 0, 2)

End Sub
Private Sub commandbutton1_Click()
' enters personal information
Dim varName$
varName$ = WordBasic.GetAddress(, "<PR_GIVEN_NAME>", 0, 1, 0, , , 1)
TxtEmpName = WordBasic.[GetAddress$](, "<PR_GIVEN_NAME>" + " " + "<PR_SURNAME>", 0, 2)
TxtOrganization = WordBasic.[GetAddress$](, "<PR_COMPANY_NAME>", 0, 2)
Title$ = WordBasic.[GetAddress$](, "<PR_TITLE>", 0, 2)
TxtEmpAddress = WordBasic.[GetAddress$](, "<PR_STREET_ADDRESS>", 0, 2)
TxtEmpCity = WordBasic.[GetAddress$](, "<PR_LOCALITY>", 0, 2)
TxtEmpState = WordBasic.[GetAddress$](, "<PR_STATE_OR_PROVINCE>", 0, 2)
TxtEmpZip = WordBasic.[GetAddress$](, "<PR_POSTAL_CODE>", 0, 2)
TxtEmpPhone = WordBasic.[GetAddress$](, "<PR_OFFICE_TELEPHONE_NUMBER>", 0, 2)
Rem txtFax = WordBasic.[GetAddress$](, "<PR_PRIMARY_FAX_NUMBER>", 0, 2)
Rem phone$ = WordBasic.[GetAddress$](, "<PR_OFFICE_TELEPHONE_NUMBER>", 0, 2)
Rem phone$ = WordBasic.[GetAddress$](, "<PR_OFFICE_TELEPHONE_NUMBER>", 0, 2)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top