Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

using WshNetwork to get username

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zSplash - 16 Oct 2006 20:07 GMT
In Word 2002, I am trying to use scripting to get the user's login name (not
the username in Options).  Without dimming wscript, I get an error "variable
not defined" (on the wscript object); if I dim wscript, I get another error
"error 424 - object required" when I set wshNetwork.  I have the reference
to the Windows Script Host Object Model set.

Private Sub getUName()
   Dim WshNetwork, UName As String, wscript
   Set WshNetwork = wscript.CreateObject("WScript.Network")
   UName = WshNetwork.UserName

What am I  missing?

TIA
Shauna Kelly - 16 Oct 2006 21:27 GMT
Hi zSplash

Have you tried this one:
How to get the username of the current user
http://www.word.mvps.org/FAQs/MacrosVBA/GetCurUserName.htm

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

> In Word 2002, I am trying to use scripting to get the user's login name
> (not the username in Options).  Without dimming wscript, I get an error
[quoted text clipped - 10 lines]
>
> TIA
Jay Freedman - 17 Oct 2006 02:27 GMT
If you still want to use scripting, just omit the "wscript." before
CreateObject:

   Dim WshNetwork, UName As String
   Set WshNetwork = CreateObject("WScript.Network")
   UName = WshNetwork.UserName

works for me.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Hi zSplash
>
[quoted text clipped - 21 lines]
>>
>> TIA
zSplash - 17 Oct 2006 17:26 GMT
Thanks Jay!

st.

> If you still want to use scripting, just omit the "wscript." before
> CreateObject:
[quoted text clipped - 38 lines]
>>>
>>> TIA

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.