Threaded comment errors

Gigiwan

New Member
Joined
Mar 31, 2021
Messages
47
Office Version
  1. 2016
Platform
  1. Windows
My excel file comments are bugged after one of my co-workers used ubuntu and saved it, now every comment on my excel file show
"
[Threaded comment]

Your version of Excel allows you to read this threaded comment; however, any edits to it will get removed if the file is opened in a newer version of Excel. Learn more"

How do i get rid of all these notes without losing the original comment?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
try
VBA Code:
Sub RemoveCommentText()
Set a = ActiveWorkbook
' look at each sheet in workbook
For Each x In a.Sheets
    'look at each comment in sheet
    For Each y In x.Comments
        ' comment text
        b = y.Shape.DrawingObject.Caption
        ' split comment text by "
        c = Split(b, Chr(34))
        d = "[Threaded comment]"
        nc = ""
        
        For Each i In c
            e = Right(Left(i, InStr(i, "]")), Len(d))
            If e = d Then
            Else
                 nc = nc + i
            End If
        Next
        y.Shape.DrawingObject.Caption = nc
    Next
Next
End Sub
 
Upvote 0
try
VBA Code:
Sub RemoveCommentText()
Set a = ActiveWorkbook
' look at each sheet in workbook
For Each x In a.Sheets
    'look at each comment in sheet
    For Each y In x.Comments
        ' comment text
        b = y.Shape.DrawingObject.Caption
        ' split comment text by "
        c = Split(b, Chr(34))
        d = "[Threaded comment]"
        nc = ""
     
        For Each i In c
            e = Right(Left(i, InStr(i, "]")), Len(d))
            If e = d Then
            Else
                 nc = nc + i
            End If
        Next
        y.Shape.DrawingObject.Caption = nc
    Next
Next
End Sub
I tried it, but all the contents within the comment section is deleted as shown below:
1641237368764.png


All i need is to get rid of all the text highlighted in yellow instead

1641237501547.png
 
Upvote 0
Ok hope the " where in the comment
Looks like highlighted text is at start of the comment each time
then following will remove nr= number of characters from start of comment string , adjust nr as need
VBA Code:
Sub RemoveCommentText()
Set a = ActiveWorkbook
' look at each sheet in workbook
For Each x In a.Sheets
    'look at each comment in sheet
    For Each y In x.Comments
        ' comment text
        b = y.Shape.DrawingObject.Caption
        ' nr of characters from start of comment
        ' to be remove include for vbLf
        
        nr = 34 ' revise as needed
        nc = Right(b, Len(b) - nr)
        
        y.Shape.DrawingObject.Caption = nc
    Next
Next
End Sub
 
Upvote 0
Previous post #4 wrong use following
VBA Code:
Sub RemoveCommentText()
Set a = ActiveWorkbook
' look at each sheet in workbook
For Each x In a.Sheets
    'look at each comment in sheet
    For Each y In x.Comments
        ' read comment text frist
        b = y.Shape.DrawingObject.Caption
        If Left(b, 1) = "[" Then
            'thread comment cell address
            c = y.Parent.Cells.Address
            '  delete new styled thread comment 2018 -----!
            ' an create a new old styled comment 
            Range(c).ClearComments
            Range(c).AddComment
            ' nr of characters from start of comment
            ' to be remove including for vbLf
            nr = 237
            Range(c).Comment.Text Text:=Right(b, Len(b) - nr)
        Else
        End If
    Next
Next
End Sub
 
Upvote 0
Previous post #4 wrong use following
VBA Code:
Sub RemoveCommentText()
Set a = ActiveWorkbook
' look at each sheet in workbook
For Each x In a.Sheets
    'look at each comment in sheet
    For Each y In x.Comments
        ' read comment text frist
        b = y.Shape.DrawingObject.Caption
        If Left(b, 1) = "[" Then
            'thread comment cell address
            c = y.Parent.Cells.Address
            '  delete new styled thread comment 2018 -----!
            ' an create a new old styled comment
            Range(c).ClearComments
            Range(c).AddComment
            ' nr of characters from start of comment
            ' to be remove including for vbLf
            nr = 237
            Range(c).Comment.Text Text:=Right(b, Len(b) - nr)
        Else
        End If
    Next
Next
End Sub
I tried this one but my comment turned from this

1641308296732.png


to this
1641308409209.png


and when i excuted the vba code,i got that error

1641308370109.png
 
Upvote 0
change
VBA Code:
b = y.Shape.DrawingObject.Caption
with
VBA Code:
b = y.Text

when you press Debug which line of the code is highlighted
 
Upvote 0
Solution
replace
VBA Code:
            Range(c).AddComment
            ' nr of characters from start of comment
            ' to be remove including for vbLf
            nr = 237
            Range(c).Comment.Text Text:=Right(b, Len(b) - nr)
with
VBA Code:
            nr = 237
            Range(c).AddComment Right(b, Len(b) - nr)
 
Upvote 0

Forum statistics

Threads
1,223,924
Messages
6,175,417
Members
452,640
Latest member
steveridge

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top