OOobbs/113
質問
Calc のアクティブシート上のコメントの全表示、非表示、削除を行うマクロ。 回答
全表示用 Sub Show_AllComments() Dim oDoc As Object, oSheet As Object Dim oAnnos As Object Dim oEnum As Object, oElm As Object oDoc = ThisComponent If oDoc.supportsService( _ "com.sun.star.sheet.SpreadsheetDocument" ) Then oSheet = oDoc.CurrentController.getActiveSheet() oAnnos = oSheet.getAnnotations() oEnum = oAnnos.createEnumeration() While oEnum.hasMoreElements() oEnum.nextElement().setIsVisible(true) WEnd End If End Sub 全非表示用 Sub Hide_AllComments() Dim oDoc As Object, oSheet As Object Dim oAnnos As Object Dim oEnum As Object, oElm As Object oDoc = ThisComponent If oDoc.supportsService( _ "com.sun.star.sheet.SpreadsheetDocument" ) Then oSheet = oDoc.CurrentController.getActiveSheet() oAnnos = oSheet.getAnnotations() oEnum = oAnnos.createEnumeration() While oEnum.hasMoreElements() oEnum.nextElement().setIsVisible(false) WEnd End If End Sub 全削除用 Sub Remove_AllComments() Dim oDoc As Object, oSheet As Object Dim oAnnos As Object Dim oEnum As Object, oElm As Object oDoc = ThisComponent If oDoc.supportsService( _ "com.sun.star.sheet.SpreadsheetDocument" ) Then oSheet = oDoc.CurrentController.getActiveSheet() oAnnos = oSheet.getAnnotations() For i = 0 To oAnnos.getCount -1 oAnnos.removeByIndex(i) Next i End If End Sub |