View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Extracting meta-data from Active Directory (AD) via mailmerge

The last time I looked (about 2 years ago) it was possible to use the OLEDB
provider for the AD to use AD as a Word mailmerge data source. e.g. in code

ActiveDocument.MailMerge,OpenDataSource _
Name:="c:\a\empty.odc", _
Connection:="Provider=ADSDSOObject;", _
SQLStatement:="SELECT * FROM 'LDAP://adsiservername'"

where empty.odc is a completely empty file that you can create in e.g.
Notepad, and adsiservername is the name of the adsi server box.

However, I get the impression that what you want to do is either
a. get some ADSI data corresponding to the individual/login name of the
person doing the merge or
b. get some ADSI data appropriate to the data in each row in another data
source.

Either way, for the data to appear as a field in the data source, you would
have to be able to get the data source to do the ADSI query. If your data
source is Jet/Access, you /might/ be able to create a Query that could do
that, using a linked table perhaps - I don't know off the top of my head. If
your data source is something like SQL Server, you /might/ be able to do the
same using an attached table and a View.

Otherwise, if it's case (a), you could consider getting the data using ADO
in a Word VBA macro each time a merge is done, and either inserting the
results directly or stroing them in a way that makes insertion relatively
simple, e.g. in a Document Property (insert using { DOCPROPERTY } field or
Document Variable (insert using { DOCVARIABLE } field.
Peter Jamieson



"medix" wrote in message
...
Hi,

I want to be able to use mail-merge in Word and pull the data for userinfo
e.g. Address, Contact telephone, Job designation,etc as stored in the AD
and
present it
as a field for ultimate mail-merge.

Most users fail to populate the Userinfo in Word.

Any help greatly appreciated.