write at exceltoexplore@gmail.com : Report Automation|Dashboard in Excel| Provide Excel consulting through macro (VBA) automation |Financial Modeling | Ethical Hacking

Monday 13 June 2011

Find systems environment Information with vb

"Environ" : This Function return various Environment details ,all the Strings associated with an operating systems environment variables
This code is useful if you need to obtain info about your users operating system. The code loops through all the Environment variables available, and returns the name of the variable, and the string value associated with it. The Environ function is used to obtain things like the Windows Username, Userprofile, System root, etc

To Find User Name & Computer Name :

Sub envn()
MsgBox Environ("Username")
MsgBox Environ("Computername")
End Sub

To Find system Info :
Sub env()
Dim i As Long
Sheets.Add
For i = 1 To 56
    Cells(i, 1).Value = Environ(i)
Next i
Columns("A").AutoFit
End Sub

No comments:

Post a Comment