Get Windows Username

  • Thread starter Thread starter Boyd
  • Start date Start date
B

Boyd

I'm using the following code with my custom form:

Sub cmdSubmit_Click()
Dim oWsNetwork
Set oWsNetwork = CreateObject("WScript.Network")
Dim strUsername
Set strUsername = oWsNetwork.UserName
Set oWsNetwork = Nothing
Item.UserProperties("UsernameHold") = strUsername
End Sub

The code is failing with the following message: "Object required:
'[string:"jsmith"]', and breaks on the line "Set strUsername =
oWsNetwork.UserName".

Any idea what the problem is?

Thanks,
Boyd
 
Never use a Set keyword when assigning a value to a non-object variable.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top