Not sure. If you comment that line does the rest work OK.
In theory that code should format the first comment line bold.
Does it error in all cases, try applying with different text and lines
(don't forget need to press Ctrl-Enter to force a new line in the textbox
Replace that line with the following
On error resume next
mCom.Shape.TextFrame.Characters(1, pos - 1).Font.Bold = True
If err.number then
msgbox err.description,,pos
err.clear
end if
on error goto 0
What's the error description, also what's the text and 'pos'
Which Excel version ?
Regards,
Peter T
"Joe_Hunt via OfficeKB.com" <u45578@uwe wrote in message
news:8a48758a7579e@uwe...
Thank you Peter. I ran into a problem though. When I tried to run this
code I
got a syntax error on this line:
mCom.Shape.TextFrame.Characters(1, pos - 1).Font.Bold = True
Any thoughts?
Peter T wrote:
Try the following for ideas.
With the curser in the textbox press F12 to 'get' next comment text and
Ctrl-F12 to 'set' comment text.
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Dim s As String, sUN As String
Static n As Long
' press F12 to write next comment to textbox
' press Ctrl-F12 to write textbox text to comment
If KeyCode = vbKeyF12 Then
If Shift = 2 Then
If Not mCom Is Nothing Then
sUN = Application.UserName & ":"
s = Replace(TextBox1.Text, vbCrLf, vbLf)
If Left(s, Len(sUN)) < sUN Then
s = sUN & vbLf & s
End If
mCom.Text Text:=s
mCom.Shape.TextFrame.Characters.Font.Bold = False
pos = InStr(2, s, vbLf)
If pos Then
mCom.Shape.TextFrame.Characters(1, pos - 1).Font.Bold
=
True
End If
End If
Else
cnt = ActiveSheet.Comments.Count
If cnt Then
n = n + 1
If n cnt Then n = 1
Set mCom = ActiveSheet.Comments(n)
TextBox1.Text = mCom.Text
Me.Caption = "Comment in cell " & mCom.Parent.Address(0,
0)
End If
End If
End If
End Sub
Up to you if you want to include the stuff about Username and first line
bold.
Regards,
Peter T
Hello all, and thank you for all the help you've given me, even though
most
[quoted text clipped - 22 lines]
appreciate
any help you can give me.
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1