Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Default field values from AD profile info??
We would like to generate a template that will default values in various
fields with information from an AD profile. For example: We have a Department field in the document. We want to set the department field value = the Department value in the users AD profile. How would this best be accomplished? Thanks, Steven |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Default field values from AD profile info??
Data manipulation is best done in the data source. What it it?
If the number of variations are not too great however, you can get by with using If...then...Else... fields that provide the appropriate response depending upon the value of the AD. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Steven Heinz" wrote in message ... We would like to generate a template that will default values in various fields with information from an AD profile. For example: We have a Department field in the document. We want to set the department field value = the Department value in the users AD profile. How would this best be accomplished? Thanks, Steven |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Default field values from AD profile info??
Assuming you mean Active Directory,
You should be able to get information from the AD provider using AD objects in VBA. I know almost nothing about this except that you can, for eaxample, get the logged-in user name using: Dim objSysinfo, objUser Set objSysinfo = CreateObject("ADSystemInfo") Set objUser = GetObject("LDAP://" & objSysinfo.UserName) I would suggest that a good way forward might be to create AutoNew and/or AutoOpen macros that query the AD and stuff the appropriate results into either Document Properties or Document variables, and use { DOCPROPERTY } or { DOCVARIABLE } fields to insert the results into the document where you need them. Document Properties are better if you want information that is visible frm outside Word and which can be modified via the User Interface. I think there may be a limit of 127, 255 or some such, on the number available. Docvariables are better if you don't want to allow users to change their values. I think you can have more of them if that's what you need, but { DOCVARIABLE } fields used to crash Word when used in headers/footers in older versions of Word. (I don't think they do now, but it's probably worth checking). Alternatively, it is 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. You can also get such data directly into a document using a DATABASE field along similar lines, e.g. { DATABASE \d "c:\\a\\empty.odc" \c "Provider=ADSDSOObject;" \s "SELECT * FROM 'LDAP://adsiservername'" } Again, I don't know enough about ADSI/LDAP structure and query syntax to know whether you can get info. for the current user without getting the current user as a preiliminary step. If you do make progress with any of these approaches it would be pretty useful if you could post code examples back in this newsgroup. Peter Jamieson "Steven Heinz" wrote in message ... We would like to generate a template that will default values in various fields with information from an AD profile. For example: We have a Department field in the document. We want to set the department field value = the Department value in the users AD profile. How would this best be accomplished? Thanks, Steven |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Enter text in a field and have it appear as entered elsewhere | Microsoft Word Help | |||
How do I set default on Toggle Field Codes? | Microsoft Word Help | |||
how to change "default text" font in a form field | Microsoft Word Help | |||
Default font - possible bulletproof fix in Word 2003 | Microsoft Word Help | |||
Text Form Field Ref in Footer Won't Update on Screen | Microsoft Word Help |