Note Code Help

  • Thread starter Thread starter scrabtree23
  • Start date Start date
S

scrabtree23

I have the following code:

On Error Resume Next
Dim curComment As String
curComment = ""
curComment = Target.Comment.Text
If curComment <> "" Then curComment = curComment &
Chr(10)
Target.AddComment
Target.Comment.Text Text:=curComment & _
ActiveWorkbook.BuiltinDocumentProperties("Author")
& _
": Rev. " & Format(Date, "mm-dd-yyyy") & ", From
(" & Worksheets("Password").Range("A16").Value & ")"



I have two problems: 1) I want it to put in the note the
person who is logged in, not the ("Author").

2) I want this note to be visibale.
 
From: Trevor Shuttleworth ([email protected])
Subject: Re: Code to show login name
Newsgroups: microsoft.public.excel.programming
Date: 2001-01-16 12:54:01 PST



Private Declare Function apiGetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nsize As Long) As Long

Sub GetUserNameTest()
MsgBox fOSUserName
End Sub

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function

-------------------

Mr. Erlandsend's site:
http://www.erlandsendata.no/english/vba/os/index.htm

has code for username and computer name.

Regards,
Tom Ogilvy
 
Back
Top