Get Windows Username

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
 
S

Sue Mosher [MVP-Outlook]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top