G
Greg
I have been being schooled here of late on writing clean
code. I don't know if this is a crime, but my normal
practice is to find what I want to do in a google search
start hacking. Several months ago I was looking for the
code to delete all comments in a documment. This is what I
found:
'Dim lngCount, lngIndex As Long
'With ActiveDocument.Comments
' lngCount = .Count
' If lngCount > 0 Then
' For lngIndex = lngCount To 1 Step -1
' .Item(lngIndex).Delete
' Next
' End If
'End With
I was looking at this today and thought I would probe why
it appeared so involved. As the idea is to just delete
all comments that it could be simplier. Here is my
hacking:
With ActiveDocument.Comments
Do Until .Count = 0
.Item(.Count).Delete
Loop
End With
Both variants work just fine. Mine seems simplier, but is
it clean?
Thanks for your time.
code. I don't know if this is a crime, but my normal
practice is to find what I want to do in a google search
start hacking. Several months ago I was looking for the
code to delete all comments in a documment. This is what I
found:
'Dim lngCount, lngIndex As Long
'With ActiveDocument.Comments
' lngCount = .Count
' If lngCount > 0 Then
' For lngIndex = lngCount To 1 Step -1
' .Item(lngIndex).Delete
' Next
' End If
'End With
I was looking at this today and thought I would probe why
it appeared so involved. As the idea is to just delete
all comments that it could be simplier. Here is my
hacking:
With ActiveDocument.Comments
Do Until .Count = 0
.Item(.Count).Delete
Loop
End With
Both variants work just fine. Mine seems simplier, but is
it clean?
Thanks for your time.