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.

username in word application?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DeCock - 13 Sep 2006 14:05 GMT
Hello,
Is it possible to detect the login userid from a computer?
I would like to find this userid and find the corresponding username in an
excel file.

Thank you.
Jean-Guy Marcil - 13 Sep 2006 15:06 GMT
DeCock was telling us:
DeCock nous racontait que :

> Hello,
> Is it possible to detect the login userid from a computer?
> I would like to find this userid and find the corresponding username
> in an excel file.

Would this help:
   http://www.mvps.org/word/FAQs/MacrosVBA/GetCurUserName.htm
?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Helmut Weber - 13 Sep 2006 15:20 GMT
Hi DeCock,

not that I understand all of this, but it seems to work.

Declare Function GetUserName Lib _
"advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
' ----------------------------------------------------
Private Function WhoAmI() As String
  Dim Buffer As String     ' Puffer fuer den Benutzernamen
  Dim BuffSize As Long     ' Groesse des Puffers
  GetUserName Buffer, BuffSize
  Buffer = Space$(BuffSize)        ' Speicherplatz reservieren
  GetUserName Buffer, BuffSize
  WhoAmI = LCase$(Left$(Buffer, BuffSize - 1))     ' '\0' entfernen
End Function

Sub Test0001()
MsgBox WhoAmI
End Sub

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Jonathan West - 13 Sep 2006 15:22 GMT
> Hello,
> Is it possible to detect the login userid from a computer?
> I would like to find this userid and find the corresponding username in an
> excel file.
>
> Thank you.

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

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Steve Yandl - 13 Sep 2006 18:28 GMT
This should get you what you want.

Sub FindUserName()
Set objNetwork = CreateObject("WScript.Network")
strUser = objNetwork.UserName
MsgBox strUser
End Sub

Steve

> Hello,
> Is it possible to detect the login userid from a computer?
> I would like to find this userid and find the corresponding username in an
> excel file.
>
> Thank you.
Russ - 02 Oct 2006 09:14 GMT
The Windows Environmental Variables are available too:

strDrive = Environ("HOMEDRIVE") 'hard drive letter the system is running on.

strPathDocs = strDrive & Environ("HOMEPATH") & "\My Documents"'current
user's place.

'current user's temp directory, if needed, to temporarily save files.
strPathTemp = Environ("TEMP")

> This should get you what you want.
>
[quoted text clipped - 12 lines]
>>
>> Thank you.

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

 
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.