I have the code below, and it works perfectly on my Mac. But... on my PC it does not.
The cell comment does not resize horizontally when I enter text. So if I enter a long comment I get a comment box that extends far to the right to fit the contents in. Vertically it is fine, nothing cut off and no extra space.
Any ideas why this would be? Any ideas how I can force the text to wrap in the cell comment box?
Thanks in advance for your help. Code is below:
The cell comment does not resize horizontally when I enter text. So if I enter a long comment I get a comment box that extends far to the right to fit the contents in. Vertically it is fine, nothing cut off and no extra space.
Any ideas why this would be? Any ideas how I can force the text to wrap in the cell comment box?
Thanks in advance for your help. Code is below:
Code:
Sub AddCom()
Const USERNAME As String = "Greer:"
Dim strCommentName As String
Dim cmnt As String
Dim NoMore As Boolean
Dim Pos As Long
cmnt = InputBox("Please enter a comment")
strCommentName = cmnt & vbLf & Now
On Error GoTo 0
With activeCell
If .Comment Is Nothing Then
strCommentName = USERNAME & Chr(10) & strCommentName
Else
strCommentName = .Comment.Text & Chr(10) & vbLf & USERNAME & Chr(10) & strCommentName
.Comment.Delete
End If
With .AddComment(strCommentName)
.Visible = False
.Shape.AutoShapeType = msoShapeRoundedRectangle
Pos = 0
Do
Pos = InStr(Pos + 1, strCommentName, USERNAME)
If Pos > 0 Then
With .Shape.TextFrame
With .Characters(Pos, Len(USERNAME)).Font
.Bold = True
.Italic = True
.ColorIndex = 3
End With
End With
End If
Loop Until Pos = 0
End With
.Comment.Shape.TextFrame.AutoSize = True
.Comment.Visible = False
End With
End Sub