openoffice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ariel Constenla-Haile <arie...@apache.org>
Subject Re: Removing condition formatting using macro
Date Tue, 08 Jul 2014 14:45:47 GMT
Hello João,

On Tue, Jul 08, 2014 at 11:02:21AM -0300, "João Paulo R. Rezende" wrote:
> Hello,
> 
> I want to create a macro to remove or clear all condition formats in current
> sheet.
> 
> I had tried:
> 
> myRange.ConditionalFormat.Clear()
> myRange.ConditionalFormat.removeByIndex(index)
> mySheet.ConditionalFormat.Clear()
> 
> Already tried,
> Dim oPropCondition As Object
> .....
> oPropCondition = oRange.ConditionalFormat
> oPropCondition.Clear()
> oRange.setPropertyValue( "ConditionalFormat", oPropCondition)
> 
> But nothing works,
> 
> How can I do this?

Please read the Developer's Guide:
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Conditional_Formats
The Note there says:

After a conditional format is changed, it has to be reinserted into the
property set of the cell or cell range. 

So your first code does not work; but the second one should, because it
is setting the conditional format back in the range.

The following code works fine:

Sub Main
 Dim oRange
 oRange = ThisComponent.getSheets().getCellByPosition(2,9,0)
          
 Dim oCF
 oCF = oRange.ConditionalFormat
 If oCF.getCount() > 0 Then
   oCF.clear()
   REM https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Conditional_Formats
   REM After a conditional format is changed, it has to be reinserted into the property set
of the cell or cell range.
   oRange.ConditionalFormat = oCF
 End If
End Sub

Change oRange to meet your need; if does not work, then it might be
a bug; if so, please submit a bug report and attach a sample document in
order to reproduce it.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

Mime
View raw message