Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADDING USER NAME TO DOCUMENT 4

Status
Not open for further replies.

FISKO

Technical User
Aug 30, 2005
113
GB
Hi is it possible to have a module in word, excell etc that grabs the username and places it on the bottom of the document when the user prints?
This would be very useful in school to find out who's wasting all the ink.
Thanks
 
macropod - true username and author are different fields, but my point was that the Word username is easily accessible to anyone. It is not a reliable field for identification purposes, which is what I said.

True, the code only goes to the last page. The assumption was that this was a full print job. There was no specified requirement (or mentioned)or spec to cover partial printing. If there had been I would have covered it within the print job. Not spec'd not coded.

True, multiple print would get multiple passes with the printing person. It was not fully spec'd out, so it was not fully coded. For all you know there may be a requirement for multiple insertions of various people who print the document. Maybe he wants a log of whiever prints it. Who knows. Don't know. Didn't put it in.

Gerry
 
Hi if word 2003 does not create a Normal.dot until changes are made to it where does word find the template it uses until changes are made?
If I give the users a new or create a Normal.dot would word use this (if I can find thew correct path to put it in?)
Thanks all of you for your contributions
 
Hi Gerry,

I take your point about the ease with which users can alter the Word username. There's an easy fix for that - simply add a line like:
If Len(Application.UserName) < 3 Then Application.UserName = Environ("Username")
or even more simply, given the context:
Application.UserName = Environ("Username")
as the last line of the code. The latter solution would clobber any attempt to do more than temporarily change the username on anything except the current open document(s) - close and re-open, or open another, and the username gets reset.

As for the rest, I'm not interested in debating the merits of different assumptions about what FISKO wants. My concern is to provide a workable solution to cover any likely scenario.

Cheers
 
Basically, Word uses its encoded default settings and doesn't require a normal.dot until a change to settings is made.

In Word XP, if you did a fresh install of Word XP (or Office XP) on a new computer and copied across an admin normal.dot Before Word had been made to create its own - Word ignored the admin normal.dot (it was diagnosing this problem that alerted us to the change).

If you upgraded from a previous installation, the installation picked up the old settings (and normal.dot), so the problem didn't occur.

I'm not sure if this was ever changed as MS says it is by design! You'll have to try it.


Regards: tf1
 
tf1 said:
But note that if this is Word 2003, normal.dot is not created until the user makes a change to the default settings that requires a normal.dot (such as changing the default font). So if the users have not made any changes to the default settings, normal.dot will not exist.

This is not exactly correct. All versions of Word need a Normal.dot Template to function. If Word cannot find one when it starts it will create one immediately before doing anything else. There is no change in behaviour in Word 2003.

If the option to "Prompt to save changes to Normal.dot" is set (under Tools > Options > Save) and the User replies "No" then it will not be saved but one is always created - and, if not saved, then recreated next time Word is invoked.

If it is saved, the location will be that specified for User Templates (under Tools > Options > File Locations).

Both the above settings are held in the Registry and are, thus, independent of Normal.dot.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
hi Fisko,

In your original post you also asked for an Excel solution. Here's some code you might like to try - it inserts the username into the right footer.
Code:
Sub UpdateUserName()
Dim oSheet As Worksheet
Dim uStart As Integer
Dim uEnd As Integer
Dim uStartText As String
Dim uEndText As String
uStartText = " User: *"
uEndText = "*"
Application.UserName = Environ("Username")
For Each oSheet In ActiveWorkbook.Sheets
    With oSheet.PageSetup
        If InStr(.RightFooter, uStartText) Then
            uStart = InStr(.RightFooter, uStartText)
            uEnd = InStr(uStart + Len(uStartText) + 1, .RightFooter, uEndText)
            .RightFooter = Replace(.RightFooter, Mid(.RightFooter, uStart, uEnd), "")
        End If
            .RightFooter = .RightFooter & " User: *" & Application.UserName & "*"
    End With
Next
End Sub

Unlike Word, Excel doesn't have the equivalent of a username field that you can use, so I've developed an alternative approach that involves the use of a pre-defined string.

For Excel, you'd need to insert the code into each user's 'Personal.xls' file and call it from the appropriate routines. Unlike Word, this file usually doesn't exist unless the user specifically creates it.

Note also how the code inserts the environment username into the application username. You may want to keep this, or comment it out.

Cheers
 
Thanks guys I really appreciate your help in finding a solution to this problem. I am going to try all the best ideas and see what works best on my school system.
Thanks once again
 
Tony

Sorry but you are wrong - I am correct. Do a fresh install of Office 2003 onto a newly formatted PC (i.e. no legacy version of Office on the system) and you will NOT find a normal.dot. It does not exist until a change is made to Word that requires to be saved to normal.dot. Word uses the default settings encoded into Word.

As soon as a setting such as Format, Font and the DEFAULT button is pressed, Word will create a normal.dot as soon as Word (and maybe Outlook) is closed. It will only prompt to save the normal.dot if the setting is checked under Tools, options, Save tab.

Word has behaved like this since OfficeXP.

Regards: tf1
 
Hi tf1,

Do a fresh install of any version of Office you like and you will not find a copy of normal.dot. Installing does not create normal.dot. It is created (if it can't be found) when Word is started and saved (subject to user settings) when Word is closed - first time, whether any non-default settings have been applied or not. This is the same in all Word versions.

You don't need a fresh install to demonstrate this - anybody can do this at any time with any version of Word.[ul]
[li]In Word, uncheck "Prompt to save changes to Normal.dot" under Tools > Options > General[/li]
[li]Close Word (and Outlook if using Word as editor - and make sure Outlook is fully closed via Task Manager if necessary)[/li]
[li]Find your Normal.dot (in the User Templates Folder - typically C:\Documents and Settings\(userid)\Application Data\Microsoft\Templates)[/li]
[li]Rename it or move it or delete it so that Word can't find it[/li]
[li]Open Word and close Word[/li]
[li]Go look in the User Templates folder for your brand new Normal.dot[/li][/ul][ul]
[li]Delete the new version and restore your old one to get back to where you were[/li][/ul]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Tony

Unchecking the Prompt to save Normal.dot is itself sufficient to force the creation of normal.dot because it is changing the settings.

You can open and close Word XP and 2003 after a virgin install and it won't create a normal.dot - subject to there being no third party add-ins that 'dirty' normal.dot (such as Adobe, Symantec and ViaVoice type add-ins).




Regards: tf1
 
Hi tf1,

Changing the Prompt to save Normal.dot setting does not affect Normal.dot at all - the value is held in the registry. But I deliberately said to do this before renaming your normal.dot so that there would be no question of a conflict.

I repeat (and anyone can try this at any time to see for themselves) that if there isn't a normal.dot available Word will create one - and save it (subject to user agreement, implicit or explicit) without any user action - at all - being taken in Word, and without any addins loaded. Have you tried this?

Next time I do a clean reinstall (barring disaster, it won't be till next year at least) I will double check what happens. Meanwhile is there any other test you can propose which might verify what you say?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
tf1 - take your virgin install; open Word for the very first time; a blank document is created...NOTHING has been changed to ANY settings....look in File > Properties. That unsaved, un-named file has....normal.dot is listed as the template. It may be non-existent, but it is still being used.

I think Tony is correct. It may in fact be a virtual normal.dot, but a normal.dot it is. It may not be be "real" enough to find on a hard disk platter (yet), but it is "real" enough in memory.

Gerry
 
Gerry

I agree that it must actually exist for that purpose. Next week when the engineers are doing an install, I will play around with it and see.

Terry

Regards: tf1
 
Make sure you let us know, as I am kind of curious myself.

Gerry
 
No problems. I'm not at work monday (shoppping day for some festival coming up!), but I should be able to run a test by Wednesday.


Regards: tf1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top