对于 OpenOffice Writer 4.0.0,确认以下代码删除文档中的所有注释。
sub RemoveAllComments2
rem ----------------------------------------------------------------------
rem Define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem Get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DeleteAllNotes", "", 0, Array())
end sub
您的原始代码适用于 Microsoft Word,在这种情况下我也提供了解决方案。对于 Word 2007、2010 和 2013,以下代码将删除活动文档中的所有注释。
Sub RemoveAllComments()
Dim n As Long
For n = ActiveDocument.Comments.Count To 1 Step -1
ActiveDocument.Comments(n).Delete
Next 'n
End Sub
意思是从1Count To 1 Step -1
开始Count
并向后计数1
。