Link addresses from Outlook 2003

G

George

Dear friends,
I need to have a dropdown menu in a template in order to select the coutry.
In my outllook 2003 I have my country contacts in separate folders, e.g.
contact1 appears in a folder named UK.
By selecting the country (UK) from the dropdown menu I would like to insert
his contact details in a new document (perhaps using mail merge). I need
this to be done automatically.

Please advice me.

Thanking you in advance.

George
 
P

Peter Jamieson

This is tricky because you would need to connect to the contacts folder
programmatically, e.g. using VBA, and as far as I know there is no reliable
way to do it. It is perhaps relevant that if you macro record the action of
selecting an Outlook contacts folder, the resulting macro is empty (Word
2003) and even in Word 2007 it contains a call to the old Wordbasic object.

You /can/ get Word to pop up the connection dialog and allow the user to
select a folder using the following VBA, but the selection dialog pops up
twice and I have not found a way to prevent that.

ActiveDocument.MailMerge.OpenDataSource _
Name:="", _
Subtype:=wdMergeSubTypeOutlook

As long as there is an active connection to /an/ Outlook contacts folder,
and as long as all the folders you want to use are subfolders of the same
main folder as that folder and they are all folders in the Outlook Address
Book, then you should be able to change the folder programmatically using
VBA. For example, to change to the "UK" folder, use:

ActiveDocument.MailMerge.DataSource.QueryString="SELECT * FROM [UK]"

NB, the name UK needs to be the name of the Outlook folder, not the name of
the Address Book in the Outlook Address Book, which can in theory be
different.

if you tend to view your Contact folders using the Contacts button in the
navigation pane in Outlook 2003, you won't see the folder hierarchy - you
need to switch to the folder view to see it. But again, as far as I know
there is no way to use a SELECT to select a folder in a different subfolder
than the one that has already been selected. I'd rather not go into the gory
details of why I think that is so.

Peter Jamieson
 
G

Graham Mayor

To add to what Peter has said, if your various Outlook contacts lists have
their properties set to be used as e-mail address books, they will all be
available from the insert address tool. You can enhance that function with
vba in Word to make sure it types the information where you want it and
there are several examples of this use at
http://www.gmayor.com/Macrobutton.htm . When the address dialog pops up you
select the contacts list you want to use and pick the name from that list
and the macro does the rest.

An alternative, using mail merge would be to create a merge document with
the fields already placed then pick the contact in Outlook and merge that
one record with the document.
http://www.gmayor.com/mailmerge_from_outlook.htm For single letters, the
first method is a bit more complex to set up, but once configured is quicker
and easier to use.

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


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

George

Thanks a lot for your help.

Let me re-phrase the question (a simpier one). I want to create a Word
template (perhaps using the mail merge), so I can have the mailing address of
a single contact (from Outlook). It happens sometimes to change the mailing
address of the contact in Outlook. The next time I open my Word template I
want to see the new address (derived from Outlook) - Update fields? How can
I do that?

Thanks a lot again.

George

Ο χÏήστης "Graham Mayor" έγγÏαψε:
 
G

Graham Mayor

I don't know a way to do this with mail merge from Outlook. Merges from
Outlook create transient temporary files for the duration. They are not
available for re-use, unless you create a permanent data file which would
not be updated by any changes to the Outlook contact. If youhave to create a
permanent data source then you might as well create an autotext entry in
Word. I have already suggested my take on the best way of doing this. It
merely requires a couple of extra steps from 'automatic'.

You might ask in the vba forum to see if anyone can come up with anything
better.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter Jamieson

Your question may be simpler but an answer probably is not (as usual!)

To do this using a MailMerge approach, you could start as follows.

Suppose you make a Word tempalte (or document - I do not think it makes much
difference in this case) that uses your Contact's folder as its Mail Merge
Data Source. Save the template/document, and re-open it, or create a new
document based on the template. At that point you will I think be asked
(twice) to select your contacts folder. That's the real problem here, as we
shall see

Let's suppose you now try to restrict your data source to the one contact
you want to use. You will need to have criteria that uniquely identify the
contact - e.g. Firstname, lastname may or may not be enough.

Open the Mail Merge Recipients dialog box, clcik the drop-down at the top of
one of the columns, and seelct Advanced to view the Query Options dialog.
You can then specify the conditions needed to select that one record. When
you get back into the Mail merge Recipients Dialog box, only one row should
be displayed. Incidentally, you could just "clear" all the entries, and
select the one you want, but then you would be relying on Word's internal,
undocumented mechanism for identifying which records you have selected and I
suspect that is best avoided.

Now close the recipients dialog box. Show the preview data including the
address that you want to see updated. Save the template. Experimentally
change the address data for the contact. When you re-open the Word template,
and select the correct contacts folder, the new data from the contact should
be displayed. However, you have to know which contacts folder to open. If
you get the wrong one, Word won't find the record you wanted.

There is another way you can go about doing this, which is to use Access to
link to a Contacts folder, then use that linked Access table as your data
source. It seems to work quite well to me and avoids some of the problems
mentioned above. At the moment I can only tell you how it works if you have
Access, but a programmatic solution may also be feasible.

Peter Jamieson
 
P

Peter Jamieson

then use that linked Access table as your data source. It seems to work
quite well to me

Except you also have to create an Access query that gets all the data from
the Access table then use /that/ as the data source.

Peter Jamieson
 
G

George

Thanks a lot my friend,

I think I will do it in Access.

Ο χÏήστης "Peter Jamieson" έγγÏαψε:
 

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