Page 1 of 1

[Solved] MouseEvent And CellBackColor

Posted: Sun Dec 28, 2014 10:03 pm
by Kiel
Hello,

In the attached example when clicked with the mouse in the cell "B4" - "RED CellBackColor" meets the B2 to P2 cells with red background color.

But moving the mouse selects cells.

How to solve this? That is, how to return control to the cells? I'm already more than a week in this routine and after several tests still can not solve it.

Any help is welcome.

Note .: - If you press the "ESC" it stops select with the mouse.
           - Setting the print command "x" also stop select with the mouse.

Thanks,

Kiel

Re: MouseEvent And CellBackColor

Posted: Mon Dec 29, 2014 12:05 am
by Zizi64
1.: Do not move the mouse, while the macro is running

2.: Use Form Control elements (Buttons) or Hyperlinks associated to separated subroutines to launch the macros.

Code: Select all

Sub ResetBackroundColor

	oDoc  = ThisComponent.CurrentSelection
	oSheet = ThisComponent.Sheets(oDoc.RangeAddress.Sheet)

    oCell=oSheet.getCellRangeByName("B2:P2")
    oCell.clearContents(23)
    oCell.CellBackColor=RGB(255,255,255)
End Sub


Sub SetBackroundColor

	oDoc  = ThisComponent.CurrentSelection
	oSheet = ThisComponent.Sheets(oDoc.RangeAddress.Sheet)

           For i=1 to 15
              oCell=oSheet.getCellByPosition(i,1)
              oCell.CellBackColor=RGB(255,51,51) 
              Wait 100 
           Next
End Sub
MouseEvent And CellBackColor.ods
(19.96 KiB) Downloaded 155 times

Re: MouseEvent And CellBackColor

Posted: Mon Dec 29, 2014 3:40 am
by Kiel
Thank Zizi64,

I studied his suggestion and will be used.

Another suggestion, which is also thank the Piaf, which follows in the attached file.

Hugs,

Kiel