I need to know how I can have a users NT domain username
autofilled into a field such as form field or another
specific location on a word doc in Office XP. I am presume
this would need a macro and if anyone has a working code
example I would love to see it. Also, if there is another
method, that would also be excellent.

-Regards
Jon

Re: NT Username auto fill-in by Jay

Jay
Thu Jun 24 21:43:22 CDT 2004

Hi Jon,

Yes, it requires a macro.

First, get the username into a string variable this way:

Dim strUserNm As String
strUserNm = Environ("Username")

Then insert that string into the document by your method of choice.
For example, if the document is a protected form with a text form
field named UserNm, the code would be

ActiveDocument.FormFields("UserNm").Result = strUserNm

Instead, the document (or the template on which it's based) could have
a bookmark named UserNm, and you could use code similar to that at
http://word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

"Jon S." <spiderboi@charter.net> wrote:

>I need to know how I can have a users NT domain username
>autofilled into a field such as form field or another
>specific location on a word doc in Office XP. I am presume
>this would need a macro and if anyone has a working code
>example I would love to see it. Also, if there is another
>method, that would also be excellent.
>
>-Regards
>Jon


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.mvps.org/word