use of WinUsername

craigexcel

Active Member
Joined
Jun 28, 2006
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
In looking for a way for VB to specifically recognize me as the person opening a workbook, I came across WinUsername. However, when the following is executed, a no (or a null?) value is returned.

Dim UserName As String
UserName = WinUsername
UserName = MsgBox("username is " & UserName, vbOKOnly)

I'm working on a company network. Is there another way for WinUsername to specifically identify me, or can you suggest alternate VB that would execute ONLY when I open the workbook? Thanks.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Here's one way:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> GetMyName()
    <SPAN style="color:#00007F">Dim</SPAN> CurrentUserName <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
        CurrentUserName = Environ("Username")
    MsgBox CurrentUserName
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

You can add a simple IF statement to validate your name after that.

HTH,

Smitty
 
Upvote 0

Forum statistics

Threads
1,214,825
Messages
6,121,788
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top