Having read Conditional Formats - Apache OpenOffice Wiki , I tried to write a macro to scan all conditional format entries in my sheet, but I could not find any. What am I missing? (The silly thing is that I had a macro somewhere that successfully did this, but I can no longer find it.)
This is the essence of my code:
sub CF_Problem_demo
dim summary as string : summary = ""
dim sheet as object : sheet = ThisComponent.CurrentController.ActiveSheet
dim formats as object : formats = sheet.Spreadsheet.ConditionalFormats.ConditionalFormats ' ¿The implementation data?
dim format as object : for each format in formats
dim entries as object : entries = format.Range.ConditionalFormat
If entries.Count <> 0 Then
summary = summary + ", " + z.Range.AbsoluteName + " has " + entries.Count + " entries"
dim entry as object : for each entry in entries
summary = summary + ": " + entry.StyleName ' Just showing we can access this
next
EndIf
next
if summary = "" then
summary = ", no conditional format entries found"
endif
summary = "Sheet '" + sheet.LinkDisplayName + "' has " + (UBound (formats) - LBound (formats) + 1) + " formats" + summary
MsgBox (summary,, "Conditional formatting")
End Sub
If I run this macro in a sheet with some manually added conditional formatting, which I can see with Format | Conditional | Manage
, it reports that it has found nothing.
Edit: Conditional formatting was added manually.
Edit: Improved my demo, previous was:
sub CF_Problem_demo
dim z_S as string : z_S = ""
dim sheet as object : sheet = ThisComponent.CurrentController.ActiveSheet
dim formats as object : formats = sheet.Spreadsheet.ConditionalFormats ' ¿The implementation data?
dim z as object : for each z in formats.ConditionalFormats
dim y as object : for each y in z.Range.ConditionalFormat
if y.Count <> 0 Then
z_S = z_S + " " + z.Range.AbsoluteName + " has " + y.Count + " conditional format entries"
EndIf
next
next
if z_S = "" then
z_S = "No conditional format entries found"
endif
z_S = "In sheet '" + sheet.Name + "': " + z_s
MsgBox (z_S,, "Conditional formatting")
End Sub