adding cell comment via VBA (bold font?)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is there a way to make part of a cell comment bold (user name in particular)
when a comment is being added via VBA?

Thanks,
 
To change the comment text to bold:
ActiveCell.Comment.Shape.TextFrame.Characters.Font.Bold = True
 
I'm using the Application.UserName here, but the principle's the same. Go by
character lengths:

Sub FormatCmt()
Dim Cmt As Comment
Dim YourName As String
Dim Text As String

Text = "Here's your comment."
With ActiveCell
YourName = Application.UserName & ":" & vbLf
Set Cmt = .AddComment(YourName & Text)
With Cmt.Shape.TextFrame
.Characters.Font.Bold = False
.Characters(1, Len(YourName)).Font.Bold = True
End With
End With
End Sub
 
Back
Top