【VBA】Get Computer Name

You can get
Computer Name“!

Use “Environ function“!

PR

VBA Code

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

Sub sampleProc()
    'Get "Computer Name"
    MsgBox Environ("COMPUTERNAME")
End Sub

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

PR

Result

You got “Computer Name“!

Computer Name
Computer Name
PR

FYI No.1

Also, you can get “User 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をコピーしました