tags:

views:

47

answers:

2

is there a way to get the name of the computer in VBA?

+2  A: 

You can do like this:

Sub Get_Environmental_Variable()

Dim sHostName As String
Dim sUserName As String

' Get Host Name / Get Computer Name    
sHostName = Environ$("computername")

' Get Current User Name    
sUserName = Environ$("username")

End Sub
Sarfraz
Looks like you found the same website that I did :)
Tommy
+2  A: 
Dim sHostName As String

' Get Host Name / Get Computer Name

sHostName = Environ$("computername")
Tommy
Note that Environ variables must be handled with care because they are a security risk (http://stackoverflow.com/questions/3366192/using-nt-login-as-part-of-sql-query-run-via-vba-in-access-2007)
Remou