Page 1 of 1
[Solved] Can't update calc cell background color
Posted: Thu Jan 25, 2018 6:40 pm
by tabsquare
Hi all, I am trying to update the cell background of the selected cell in calc.
Code: Select all
sub changecolor()
dim oCell
oCell = ThisComponent.getCurrentSelection()
oCell.CellBackColor = RGB(0,204,0)
End Sub
however nothing happens when I launch the macro. If I add the code
It will work. But I actually don't want the text content to be modified. Any idea? thx
Re: Can't update calc cell background color
Posted: Thu Jan 25, 2018 7:22 pm
by FJCC
Your original code, without the setString(), works for me on both Windows 10 and Linux Mint. I can't think of any setting that would change this but I will give it some more thought.
Re: Can't update calc cell background color
Posted: Thu Jan 25, 2018 7:30 pm
by tabsquare
Don't know, I tried many and many times and seems an odd behavior. I'm win 10 with OO 4.1.2. Thx
Re: Can't update calc cell background color
Posted: Thu Jan 25, 2018 8:50 pm
by tabsquare
Ok I know why it does this. In fact it works in blank cells. It isn't working on cells I previously created a lot of time ago so I didn't realize. A sample cell contains this kind of code
Code: Select all
=G756+"744:00:00"+T(STYLE(IF(NOW()>G756+"744:00:00";"red";"normal")) )
it is obviously refreshing the color to red even if the macro sets it to green.
I am quite surely supposed to change this code at macro runtime. Working on this. Thanks for taking the time to take a look into this. My fault.
Re: Can't update calc cell background color
Posted: Thu Jan 25, 2018 9:01 pm
by FJCC
Thanks for coming back to explain what the problem was. Others may find that useful.