[Solved] Removing conditional format from sheet

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
Mr.Dandy
Posts: 427
Joined: Tue Dec 11, 2012 4:22 pm

[Solved] Removing conditional format from sheet

Post by Mr.Dandy »

Hello forum,

I try to remove with a script a conditional format for a specified range:

Code: Select all

Sub RemoveCF
	oDoc = ThisComponent
	oSheet = oDoc.CurrentController.ActiveSheet
	oRange = oSheet.getCellRangeByName("A1:A3")
	oCF = oRange.ConditionalFormat
	msgbox oCF.Count & " CF detected before removing"
	oCF.clear()
	msgbox oCF.Count & " CF detected after removing"
End Sub
clear method seems working because the 2nd msgbox displays 0.
But the CF is still present.
If I inspect A1:A3 with MRI, this range is in its previous state. :(
Attachments
cond_format.ods
Sample document to reproduce
(10.72 KiB) Downloaded 180 times
Last edited by Mr.Dandy on Fri Apr 29, 2016 5:20 pm, edited 1 time in total.
OpenOffice 4.1.12 - Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Removing conditional format from sheet

Post by Villeroy »

Assign the modified oCF object to the range: oRange.ConditionalFormat = oCF
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Mr.Dandy
Posts: 427
Joined: Tue Dec 11, 2012 4:22 pm

Re: Removing conditional format from sheet

Post by Mr.Dandy »

:bravo:
OpenOffice 4.1.12 - Windows 10
Post Reply