Is it possible to call the login name of the user into a combobox?
Are you talking about Windows User? If so please check this: http://support.microsoft.com/kb/161394
__________________________
Regards,
Happy New Year!
Artem Taturevych
Application Engineer at Intercad
http://intercad.com.au/
Tel: +61 2 9454 4444
In VSTA (or a .Net addin) just use System.Environment.Username
In a VBA or VB6 macro, you need to use a WShell object:
Function UserName()
Dim myShell
Dim content
Dim value
Set myShell = CreateObject("WScript.Shell")
For Each value In myShell.Environment("PROCESS")
content = Split(value, "=")
If content(0) = "USERNAME" Then UserName = content(1)
Next
'If UserName = "" Then UserName = "-"
Set myShell = Nothing
End Function
Sorry for the sound of ignorance, but how do I apply this code to a combobox.
I'm new to programming and I am currently utting and copying code.
If the name of your combobox ComboBox1 just call:
ComboBox1.AddItem "Name"
or if the name returned by the function:
ComboBox1.AddItem GetUserName()
where the GetUserName is the function returning user name
Works perfectly, Thanks Simon & Artem.
Are you talking about Windows User? If so please check this: http://support.microsoft.com/kb/161394
__________________________
Regards,
Happy New Year!
Artem Taturevych
Application Engineer at Intercad
http://intercad.com.au/
Tel: +61 2 9454 4444
In VSTA (or a .Net addin) just use System.Environment.Username
In a VBA or VB6 macro, you need to use a WShell object:
Function UserName()
Dim myShell
Dim content
Dim value
Set myShell = CreateObject("WScript.Shell")
For Each value In myShell.Environment("PROCESS")
content = Split(value, "=")
If content(0) = "USERNAME" Then UserName = content(1)
Next
'If UserName = "" Then UserName = "-"
Set myShell = Nothing
End Function
Sorry for the sound of ignorance, but how do I apply this code to a combobox.
I'm new to programming and I am currently utting and copying code.
If the name of your combobox ComboBox1 just call:
ComboBox1.AddItem "Name"
or if the name returned by the function:
ComboBox1.AddItem GetUserName()
where the GetUserName is the function returning user name
__________________________
Regards,
Happy New Year!
Artem Taturevych
Application Engineer at Intercad
http://intercad.com.au/
Tel: +61 2 9454 4444
Works perfectly, Thanks Simon & Artem.