【VBA】Get User Name

You can get
User Name“!

Use “Environ function“!

PR

VBA Code

You can get “User Name” by “Environ function“.

Sub sampleProc()
    'Get "User Name"
    MsgBox Environ("USERNAME")
End Sub

Set “USERNAME” to “Environ function“(Line 3).

PR

Result

You got “User Name“!

User Name
User Name
PR

FYI No.1

Also, you can get “Computer Name“.

For more information, see the following article:

PR

FYI No.2

Also, you can get “path to the Desktop“.

For more information, see the following article:

PR

FYI No.3

For more information about following, see the following official online manual:

Environ function

タイトルとURLをコピーしました