![]() |
Need syntax for If user name in before save event
I am trying to execute code in BeforeSave in ThisWorkbook when the user's name is Mike. I tried the following but it does not work If Environ("UserName") = "Mike" then Msgbox Environ("UserName") I also tried the following but it does not work either: User = Environ("UserName") If User = "Mike" Then MsgBox User I must not be using the correct syntax. Can someone help? Thanks a lot. mikeburg -- mikeburg ------------------------------------------------------------------------ mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581 View this thread: http://www.excelforum.com/showthread...hreadid=508723 |
Need syntax for If user name in before save event
What do you mean "does not work"? Are you sure the UserName is
actually 'Mike'. Note that Environ("UserName") returns the user's network logon name, not the UserName listed in Tools, Options, General. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "mikeburg" wrote in message ... I am trying to execute code in BeforeSave in ThisWorkbook when the user's name is Mike. I tried the following but it does not work If Environ("UserName") = "Mike" then Msgbox Environ("UserName") I also tried the following but it does not work either: User = Environ("UserName") If User = "Mike" Then MsgBox User I must not be using the correct syntax. Can someone help? Thanks a lot. mikeburg -- mikeburg ------------------------------------------------------------------------ mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581 View this thread: http://www.excelforum.com/showthread...hreadid=508723 |
Need syntax for If user name in before save event
. . . not the UserName listed in Tools, Options,
General. which is returned with application.UserName In case you need to know. -- Regards, Tom Ogilvy "Chip Pearson" wrote in message ... What do you mean "does not work"? Are you sure the UserName is actually 'Mike'. Note that Environ("UserName") returns the user's network logon name, not the UserName listed in Tools, Options, General. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "mikeburg" wrote in message ... I am trying to execute code in BeforeSave in ThisWorkbook when the user's name is Mike. I tried the following but it does not work If Environ("UserName") = "Mike" then Msgbox Environ("UserName") I also tried the following but it does not work either: User = Environ("UserName") If User = "Mike" Then MsgBox User I must not be using the correct syntax. Can someone help? Thanks a lot. mikeburg -- mikeburg ------------------------------------------------------------------------ mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581 View this thread: http://www.excelforum.com/showthread...hreadid=508723 |
Need syntax for If user name in before save event
What I mean is that anything within the If statement does not execute. Yes, I am sure that UserName is mike, because I can put the following in the before save event & the message box displays the word Mike Msgbox Environ("UserName") Also, thanks for your comment about the log on name. I didn't realize that. What would be the code to MsgBox the user name in Tools, Options, General? However, more importantly, how can I get the If statement to work? If Environ("UserName") = "Mike" then Msgbox Environ("UserName") Thanks for your replys. mikeburg -- mikeburg ------------------------------------------------------------------------ mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581 View this thread: http://www.excelforum.com/showthread...hreadid=508723 |
Need syntax for If user name in before save event
What would be the code to MsgBox the user name in Tools,
Options, General? MsgBox Application.UserName However, more importantly, how can I get the If statement to work? Your code should work. Are you sure capitalization is correct? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "mikeburg" wrote in message ... What I mean is that anything within the If statement does not execute. Yes, I am sure that UserName is mike, because I can put the following in the before save event & the message box displays the word Mike Msgbox Environ("UserName") Also, thanks for your comment about the log on name. I didn't realize that. What would be the code to MsgBox the user name in Tools, Options, General? However, more importantly, how can I get the If statement to work? If Environ("UserName") = "Mike" then Msgbox Environ("UserName") Thanks for your replys. mikeburg -- mikeburg ------------------------------------------------------------------------ mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581 View this thread: http://www.excelforum.com/showthread...hreadid=508723 |
Need syntax for If user name in before save event
Thanks so very, very much. The login is set to mike when my if statement contained "Mike". I don't know why sometimes I have trouble with the simplest things. Oh well, at least now I know the difference between the two users. mikeburg -- mikeburg ------------------------------------------------------------------------ mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581 View this thread: http://www.excelforum.com/showthread...hreadid=508723 |
All times are GMT +1. The time now is 06:21 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com