application.username

D

Donald Stockton

I'm trying to use <application.username> in a footer, but seems that it
is only printing out as text [application.username] and not the actual
User's Name. Can this be done?

D.S.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
B

Bob Phillips

Hi Donald,

This works for me

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


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
F

Frank Kabel

Hi
add the following code to your workbook module:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet
For Each wkSht In me.worksheets
With wkSht.PageSetup
.CenterFooter = Application.UserName
End With
Next wkSht
End Sub
 
D

Donald Stockton

I guess part of my problem is that I'm also trying to include some
formatting instruction in the footer. For instanc, my original code
line is this:
.RightFooter = "&D &T &""Brush Script MT,Italic""&14&UJ. Smith"

What I'm trying to do is replace <J. Smith> with <application.username>,
but haven't figured out the correct syntax to make it work.

D.S.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
C

Chip Pearson

Donald,

Try

RightFooter = "&D &T &""Brush Script MT,Italic""&14" & _
Application.UserName

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

I guess part of my problem is that I'm also trying to include
some
formatting instruction in the footer. For instanc, my original
code
line is this:
RightFooter = "&D &T &""Brush Script MT,Italic""&14&UJ.
Smith"

What I'm trying to do is replace <J. Smith> with
<application.username>,
but haven't figured out the correct syntax to make it work.

D.S.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
F

Frank Kabel

Hi
just concatenate the username. e.g.
RightFooter = "&D &T &""Brush Script MT,Italic""&14 &
application.username
 
B

Bob Phillips

Could I also suggest that, just in case you have numeric Usernames (they are
only ids after all) that you use

RightFooter = "&D &T &""Brush Script MT,Italic""&14 " &
Application.UserName

The extra space stops some unusual output (thanks to whoever it was that
suggested taht in a previous post of min, I think it was Chip, but I am not
sure).

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
D

D.S.

Thanks to all, that works. The extra space seems like a good safe guard to
keep a name beginning with a number from getting processed as part of the
font size.
 

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