I'm forced to conclude that I have an "Error 1004: Idiotic User" because I cannot now reproduce the condition of truncated results. I must have been using a truncated file (less cells, less comments) to get less results. Nonetheless I will post the code, in shame and humility, since you asked. I humbly apologize for what now appears to be a false trail which was inexcusably in my control.
Sub test_Save_AllSheetCommentsAsTextFile()
'Save all worksheets' comment info in a text file
'Active sheet and selection are both affected
Dim wksht As Worksheet, c As Range
Dim i As Integer, j As Integer
Dim strFileName As String
Dim bNoComments As Boolean
Dim lct As Long
Dim oArea As Range
Close #1 'redundant safety close
strFileName = "foo.bar"
Open strFileName For Output As #1 'open the file for output
Print #1, "Comments in workbook " & ActiveWorkbook.Name
'The following logic gives an unpredictably/inconsistently sorted order of output; other ways are under testing
'walk each sheet;
'Selection.SpecialCells(xlCellTypeComments).Select on each;
'for each c in selection
'print #1 "cell " & this...
'Mid(c.Address,2,InStr(2,c.Address,"$")-2)
' & c.row & ":{" & c.comment & c.Comment.text & "}" & iif(not c.Comment.Visible,"(invisible)","")
#Const USE_JKP = true
#If USE_JKP Then
Print #1, "area" 'JKP "Area" approach follows
#Else
Print #1, "intersect"
#End If
For Each wksht In Worksheets
wksht.Activate
bNoComments = False
On Error GoTo err2_Save_AllSheetCommentsAsTextFile
Selection.SpecialCells(xlCellTypeComments).Select
On Error GoTo 0
If Not bNoComments Then
#If USE_JKP Then
For Each oArea In Selection.Areas
For lct = 1 To oArea.Cells.Count
With oArea.Cells(lct)
'MsgBox "row:" & .Row & "; col=" & .Column
Print #1, wksht.Name & " cell " & Mid(.Address, 2, InStr(2, .Address, "$") - 2) & .Row & ":{" _
& .Comment.Text & "}" ' & IIf(Not .Comment.Visible, "(invisible)", "")
End With
Next
Next
#Else
For j = 1 To ActiveSheet.UsedRange.Rows.Count
If Not Intersect(Selection, Rows(j)) Is Nothing Then
For Each c In Intersect(Selection, Rows(j))
Print #1, wksht.Name & " cell " & Mid(c.Address, 2, InStr(2, c.Address, "$") - 2) & c.Row & ":{" _
& c.Comment.Text & "}" ' & IIf(Not c.Comment.Visible, "(invisible)", "")
Next
End If
Next
#End If
End If
Next wksht
Close #1
Exit Sub
err2_Save_AllSheetCommentsAsTextFile:
bNoComments = True
Resume Next
End Sub