[Solved] MouseEvent And CellBackColor

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
Kiel
Posts: 44
Joined: Wed Nov 26, 2014 5:28 pm

[Solved] MouseEvent And CellBackColor

Post 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
Attachments
MouseEvent And CellBackColor.ods
(11.79 KiB) Downloaded 193 times
Sheet1.png
Last edited by Kiel on Mon Dec 29, 2014 3:42 am, edited 2 times in total.
OpenOffice 3.4 - LibreOffice 4.0 / 4.1 / 4.2 on Windows Seven
User avatar
Zizi64
Volunteer
Posts: 11482
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: MouseEvent And CellBackColor

Post 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 197 times
Last edited by Zizi64 on Mon Dec 29, 2014 10:46 am, edited 1 time in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Kiel
Posts: 44
Joined: Wed Nov 26, 2014 5:28 pm

Re: MouseEvent And CellBackColor

Post 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
Attachments
[Solved] MouseEvent And CellBackColor.ods
(18.75 KiB) Downloaded 218 times
OpenOffice 3.4 - LibreOffice 4.0 / 4.1 / 4.2 on Windows Seven
Post Reply