View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Random Poster Random Poster is offline
external usenet poster
 
Posts: 3
Default Removal of author from Comments

"Tom Ogilvy" wrote in news:#U0bYyX1FHA.1040
@TK2MSFTNGP14.phx.gbl:

Only by parsing it out.

the whole think is just a single text string
Sub ae()
Dim rCell As Range
Dim sStr As String
Dim ipos As Long
Set rCell = Range("D6")
sStr = rCell.Comment.Text
ipos = InStr(1, sStr, ":", vbTextCompare)
sStr = Trim(Right(sStr, Len(sStr) - ipos))
MsgBox "You have comment which says " & sStr

End Sub




Tom's too quick for me!! I put together a function that does the same
type of thing. The main difference is that it looks for the colon
followed by a new line.

I don't know about others but I delete the author line of almost every
comment I create. A list of potential authors (Application.Username)
might be useful.

Another option might be to look at the font and remove the bold
characters from the beginning.


HTH




Public Function CommentText(c As Range, _
Optional RemoveAuthor As Boolean = False)

Dim CommentLength As Integer
Dim CommentStart As Integer

If c.Comment Is Nothing Then
CommentText = ""
Exit Function
End If

CommentText = c.Comment.Text
CommentLength = Len(CommentText)
CommentStart = InStr(1, CommentText, ":" & Chr(10), vbTextCompare)
CommentStart = CommentStart + IIf(CommentStart 0, 1, 0)

If RemoveAuthor Then _
CommentText = Mid(CommentText, CommentStart, CommentLength)

End Function