PDA

View Full Version : Solved: Display user name using msg box function



rajagopal
03-26-2009, 04:24 AM
When the user open the excel file, i want the user name to be appeared in the message as below:

Dear Username, We welcome you to the survey.
Have a great day ahead!

Can you give me the codes for this?

maxhayden
03-26-2009, 04:54 AM
I can't give you advice on the code for this but I can recommend instead of saying "Have a great day ahead", I'd just say "Have a great day".

Kenneth Hobs
03-26-2009, 05:13 AM
Eviron() gives you their logon name. Application.UserName gives you their Excel name which is less reliable.
Sub Hi()
MsgBox "Dear " & Environ("username") & ", we welcome you to the survey." & _
vbCr & "Have a great day ahead!", vbExclamation, "Greetings"
End Sub

rajagopal
04-02-2009, 07:12 AM
Thanks.