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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display the users name when the document is printed.

Status
Not open for further replies.

taylo40

IS-IT--Management
Aug 27, 2003
52
GB

Can anyone help ?

The company I am working for is interested in printing the users name when the Excel spreadsheet is printed. The users name will appear in the footer of the spreadsheet.

The name should be mandatory.

The reason for the question is that if there is a solution for the question, if a document is printed without authorisation, the business will know the source.

Hope this makes sense.

J

 
in the VBeditor locate the ThisWorkbook object and edit the code behind it. paste the following to this code sheet

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftHeader = Application.UserName
End Sub

Matthew

crazy times call for crazy people


CrazyPabs


sometimes I wonder why I even bova...
 
Hi
As Application.username can easily be changed (TOOLS>OPTIONS), depending on how important this requirement is I'd suggest using
environ("username")
in replace of application.username in Matthew's solutions above.

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
I agree qwith Loomah. Environ("username") picks up the network logon name. NOTE: this is a environment variable and MUST exist in the environment varaiable collection in order to be used. However, if people are on a network this is pretty much a given.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top