hello everyone i need to get usernames of people who have opened the document im currently working on. Is this possible? If anyone can provide me a pseudo code would be great. thank you ahmed
create a module: Option Explicit 'Declare for call to mpr.dll. Declare Function WNetGetUser Lib "mpr.dll" _ Alias "WNetGetUserA" (ByVal lpName As String, _ ByVal lpUserName As String, lpnLength As Long) As Long Const NoError = 0 'The Function call was successful Function GetUserName() As String 'Buffer size for the return string. Const lpnLength As Long = 255 'Get return buffer space. Dim status As Integer 'For getting user information. Dim lpName, lpUserName As String 'Assign the buffer size constant to lpUserName. lpUserName = Space$(lpnLength + 1) 'Get the log-on name of the person using product. status = WNetGetUser(lpName, lpUserName, lpnLength) 'See whether error occurred. If status = NoError Then 'This line removes the null character. Strings in C are null- 'terminated. Strings in Visual Basic are not null-terminated. 'The null character must be removed from the C strings to be used 'cleanly in Visual Basic. lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1) End If 'Display the name of the person logged on to the machine. GetUserName = lpUserName End Function in your document: Dim USERID USERID = GetUserName strusr = USERID to get the full name of user use: Dim objAdSys, objUser Set objAdSys = CreateObject("ADSystemInfo") Set objUser = GetObject("LDAP://" & objAdSys.UserName) strUName = (objUser.Get("displayName")) Bryan "FotoArt" wrote: > hello everyone > i need to get usernames of people who have opened the document im currently > working on. > Is this possible? > If anyone can provide me a pseudo code would be great. > thank you > ahmed
FotoArt 's wild thoughts were released on Fri, 10 Oct 2008 06:14:00 -0700 bearing the following fruit: >hello everyone >i need to get usernames of people who have opened the document im currently >working on. >Is this possible? >If anyone can provide me a pseudo code would be great. >thank you >ahmed If you want to grab the username whenever the document is opened then it really depends on where you want to get the name from The PC Environ("UserName") Word Application.UserName -- Jan Hyde (VB MVP) https://mvp.support.microsoft.com/profile/Jan.Hyde
"FotoArt" wrote in message news:41441E1F-63D5-405C-9BE0-0DCC1B63A8FA@microsoft.com... > hello everyone > i need to get usernames of people who have opened the document im > currently > working on. > Is this possible? > If anyone can provide me a pseudo code would be great. > thank you > ahmed Not clear what you want. Do you mean 1. Get the user names of everybody who has opened the document in the past? 2. Get the user names of everybody who has opened and edited the document in the past? 3. Get the user names of everybody who has the document open at the moment? #1 simply isn't available. #2 is possible, you can use the Protect method to protect the document for revisions, send the document out for people to edit and then get the list of Reviewers. #3 is also not possible. -- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup