Hi there,
first of all: Great to be here & posting my first thread.
I’d like to highlight a whole row when choosing a cell.
I did some research & found a macro which actually works great:
EM ***** BASIC *****
global noldrow as integer
global osheet as object
global bfirst as boolean
Sub S_change_cellbackcolor_in_actual_row(event)
if not bfirst then goto 100
S_remove_cellbackcolor_in_old_row
100:
ocell = event
if ocell.supportsservice("com.sun.star.sheet.SheetCell") then
ocelladdress = ocell.celladdress
nsheet = ocelladdress.sheet
osheet = thiscomponent.sheets(nsheet)
nRow = ocelladdress.Row
noldrow = nRow
orange = osheet.getcellrangebyposition(0,nRow,27,nRow)'A=1 bis AB=27
if orange.CellBackColor <> RGB(180,199,220) then ThisComponent.getDocumentProperties().UserDefinedProperties.oldfarbe = orange.CellBackColor
orange.CellBackColor = RGB(180,199,220)
orange.CharWeight = com.sun.star.awt.FontWeight.BOLD
endif
bfirst = true
End Sub
Sub S_remove_cellbackcolor_in_old_row
orange = osheet.getcellrangebyposition(0,noldRow,27,noldRow)'A=1 bis AB=27
orange.CellBackColor = ThisComponent.getDocumentProperties().UserDefinedProperties.oldfarbe
orange.CharWeight = com.sun.star.awt.FontWeight.NORMAL
End Sub
Sub Errortest
On Error GoTo Handler
i = 1/(1)
Exit Sub
Handler:
msgbox "Error: " & Error
End Sub
The problem is the following:
I’m using already some background color in the rows, but executing the macro all my previous background colors are gone, i. e. deleted. That’s why, for example, a previous red row, in the end appears only white.
How can I fix this?
How do I have to change the above macro?
Thanks in advance for your advices & support!
Chipy