Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook - Using Forms (http://www.outlookbanter.com/outlook-using-forms/)
-   -   Get Windows Username (http://www.outlookbanter.com/outlook-using-forms/44790-get-windows-username.html)

Boyd March 29th 07 08:03 PM

Get Windows Username
 
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


Sue Mosher [MVP-Outlook] March 29th 07 08:33 PM

Get Windows Username
 
Never use a Set keyword when assigning a value to a non-object variable.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Boyd" wrote in message ups.com...
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


Boyd March 29th 07 09:01 PM

Get Windows Username
 
Perfect!
Thanks Sue.



All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com