"Computer Name" in header/footer autotext?

F

Fred Holmes

Word 2003. WinXP

In the View: Header and Footer toolbar, there is an "Insert Autotext"
button with a list of handy information, including "Filename and
Path."

I'd like to expand this to add information as to the computer that the
document file exists on, e.g., the computer's network name or any
other readily available configuration variable. Or alternatively the
username of the currently logged on user.

If the working document were kept in "My Documents" (or even on the
desktop) the username in the path to "My Documents" would satisfy this
requirement, but in the company I'm working for, "C:\data\"
substitutes for "My Documents" and is set to be regularly backed up by
a network backup process, while "My Documents" is not. Since everyone
has a "C:\data\" directory, it isn't distinctive as to user. Perhaps
there is some way to parse the username out of the path to "My
Documents" or some such?

Thanks,

Fred Holmes
 
J

Jezebel

The UserName is contained in the Author field (should be, anyway) -- so you
can use { DocProperty Author } to insert it in a document. Computer name is
a little trickier -- it's not built in but it is available through the
Environ() collection. You'll need to create your own Document Property for
the purpose. Using VBA it would be something like --

ActiveDocument.CustomDocumentProperties.Add Name:="Computer", _
LinkToContent:=False, _
Type:=msoPropertyTypeString, _
Value:=Environ("ComputerName")

Then in the document, use { DocProperty Computer } to display the value.
 
F

Fred Holmes

Many thanks. The ComputerName suggestion should work. I'll work on
it.

However, the value of the "Author" field in document properties won't
be useful, as it remains the same (the original author) upon
successive modification by other people as the document is passed
around. I need a reference to the computer where the document was
printed from (and where, presumably, the latest modification was
made).
 
J

Jezebel

UserName should be available -- Word uses it to identify the author of
comments when a document is circulated.
 

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