Login name

Is it possible to call the login name of the user into a combobox?

SolidworksApi macros
Answers 5
AT
AT 2013-01-02 Best Answer

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

ST
ST 2013-01-03

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

SS
SS 2013-01-03

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.

AT
AT 2013-01-03

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

SS
SS 2013-01-03

Works perfectly, Thanks Simon & Artem.