Note Code Help

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.
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top