Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
showing Active Directory fields within MS Word
Hello,
Me, MS Word and coding are trouble at the best of time. I have a request and am hoping you might be able to help me out. I am wanting to suck out some data from our Active Directory and put in to word if possible. QUESTION 1: When person logs on to a workstation within the domain; fields such as username, full name and email properties are attached right?? - I hope so... QUESTION 2: How does one get the fields (i.e. email address, username and fullname) on to a word document? - the reason I ask is because I have been assigned the task to create a template so the user just has to type the message within the template and ideally not have to fill in any particulars regarding to Full Name, email address etc... QUESTION 3: Am I going about this all the wrong way? - is there an alternative? Many thanks in advance, Grant |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
showing Active Directory fields within MS Word
On 3 Dec 2006 18:41:41 -0800, "Grant Mantle"
wrote: Hello, Me, MS Word and coding are trouble at the best of time. I have a request and am hoping you might be able to help me out. I am wanting to suck out some data from our Active Directory and put in to word if possible. QUESTION 1: When person logs on to a workstation within the domain; fields such as username, full name and email properties are attached right?? - I hope so... Not exactly, but the effect is the same. You can get the login name of the current user by calling a function in the operating system of the local machine. The code is at http://www.word.mvps.org/FAQs/Macros...urUserName.htm. For all the other stuff, you have to contact the Active Directory, using something called LDAP (Lightweight Directory Access Protocol). To do this you write code that uses Active Directory Service Interfaces (ADSI). You can do this stuff from inside a VBA macro in Word. When you start chasing down the documentation, most of the examples will be in VBScript, but you can usually just paste it into a VBA macro and it works. The main difference is that you don't use WScript.Echo for output -- if you want to see output, replace WScript.Echo with Debug.Print and open the Immediate Window of the VBA editor. QUESTION 2: How does one get the fields (i.e. email address, username and fullname) on to a word document? - the reason I ask is because I have been assigned the task to create a template so the user just has to type the message within the template and ideally not have to fill in any particulars regarding to Full Name, email address etc... There's an ADSI primer starting at http://www.microsoft.com/technet/scr....mspx?mfr=true that will show you, in particular, how to read properties of ADSI objects. You'll need to know the full name of the domain that contains the Active Directory; the primer's examples use the made-up domain na.fabrikam.com. QUESTION 3: Am I going about this all the wrong way? - is there an alternative? No alternative unless you want to write your own directory service from scratch. :-) Many thanks in advance, Grant -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word should catalog misspelled words to study. | Microsoft Word Help | |||
How to put graphics on envelopes? | Microsoft Word Help | |||
Change paper size; Word changes to invalid margins | New Users | |||
hard space between words. | Microsoft Word Help | |||
In Word, how can I see all files (*.*) in "save as"? | New Users |