I am trying to record a macro that selects the cell to the left of the button, shifts up to two cells further to the left, applies the overwritten landing to the letters, and changes the font color. Everything works fine, the problem is that if I apply the same macro to another button it changes the cells of the previous button. That is, you would have to record a different macro for each line. Is there a way around this to make Libreoffice understand that it just have to follow the procedure with the cell immediately to the left of the cell where the button is?
Another thing, how to apply a second macro when we "deselect" the check box?
Thanks for your attention!
Macro to Select Cell to the Left and Second Macro do Check B
-
- Posts: 1
- Joined: Thu Aug 01, 2019 6:12 pm
Macro to Select Cell to the Left and Second Macro do Check B
Libreoffice Calc 6.2.5.2 (x86) Windows 32 Bits
Re: Macro to Select Cell to the Left and Second Macro do Che
Same question posted at AskLibreOffice
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
Re: Macro to Select Cell to the Left and Second Macro do Che
READ your recorded macro and you'll find it didn't base on the "cell left of the button" but on the specific cell you selected during recording.
In other words: You need to change the assignment of that cellname (address) to the repective argsX(...).Value property to an assignment meeting your needs.
This said, it seems clear to me that your actual problem is: "How do I get the address (and sheet?) of the cell left of the button I clicked?"
First part of the problem now is how to DEFINE the "cell left of the button". Button areas are not bound to be congruent with any cell area. Cells may be hidden...
Second part is that a button not anchored to a cell but to the sheet has no simple answer to the question.
In other words: You need to change the assignment of that cellname (address) to the repective argsX(...).Value property to an assignment meeting your needs.
This said, it seems clear to me that your actual problem is: "How do I get the address (and sheet?) of the cell left of the button I clicked?"
First part of the problem now is how to DEFINE the "cell left of the button". Button areas are not bound to be congruent with any cell area. Cells may be hidden...
Second part is that a button not anchored to a cell but to the sheet has no simple answer to the question.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Macro to Select Cell to the Left and Second Macro do Che
As often I was interested in the question for reasons not related to actual needs.
The result of my investigation is contained in the attachment. It was created under LibreOffice V6.3.0.2RC and worked also for me in AOO V4.1.5 and in LibO V5.4.4.
As always I am interested in criticism and in suggestions how to do it better or simpler.
In case of controls anchored to the sheet (see my above post) we would need to add up the widths of columns and the heights of rows till we find the cell where the top-left corner of the ControlShape is located. It's pure fun. (We cannot work with the .PosSize of the control because it gives different values for reasons unknown to me.)
The result of my investigation is contained in the attachment. It was created under LibreOffice V6.3.0.2RC and worked also for me in AOO V4.1.5 and in LibO V5.4.4.
As always I am interested in criticism and in suggestions how to do it better or simpler.
In case of controls anchored to the sheet (see my above post) we would need to add up the widths of columns and the heights of rows till we find the cell where the top-left corner of the ControlShape is located. It's pure fun. (We cannot work with the .PosSize of the control because it gives different values for reasons unknown to me.)
- Attachments
-
- ask203096aoo98840andIdentifyShapeBasedOnControl_1.ods
- (11.07 KiB) Downloaded 159 times
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Macro to Select Cell to the Left and Second Macro do Che
Lupp: posSize usually gives pixels. If you position your button in the first column it will give an error, or if aligned on a column boundary the cell to the left of the cell to the left.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Macro to Select Cell to the Left and Second Macro do Che
Thanks for your reply!
Your statement on boundaries seems to address the case where not an .Anchor can be used. I had implemented that case, too but threw that away due to my lacking knowledge about the pixel size in mm (regarding your explanation).
Do you also know a simpler way to get the shape or would you suggest to do it based on the pixel measures taken from the properties of the control itself?
I should have known that. Thanks!JeJe wrote:posSize usually gives pixels.
This was clear to me. I didn't try to get the code "foolproof". Having activated the On-Error-clause the Sub will exit in any error case.JeJe wrote:If you position your button in the first column it will give an error, ...
Your statement on boundaries seems to address the case where not an .Anchor can be used. I had implemented that case, too but threw that away due to my lacking knowledge about the pixel size in mm (regarding your explanation).
Do you also know a simpler way to get the shape or would you suggest to do it based on the pixel measures taken from the properties of the control itself?
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Macro to Select Cell to the Left and Second Macro do Che
Don't know a simpler way to get the shape - but no expert there. Would looping through the columns widths and comparing the sum to the position of the button perhaps be better? I've forgotten how to convert pixels to 100ths of a mm though.
colwidth= thiscomponent.sheets(0).getColumns.getByIndex(whatevercolumn).getPropertyValue("Width",0)
colwidth= thiscomponent.sheets(0).getColumns.getByIndex(whatevercolumn).getPropertyValue("Width",0)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Macro to Select Cell to the Left and Second Macro do Che
(Sorry. I slept a bit and had a breakfast then.)
For LibreOffice:
https://api.libreoffice.org/docs/idl/re ... eInfo.html ande.g.
I would suppose that's old and unchanged stuff. It should be the same in AOO from the beginning.
BUT: I did not yet find the (a) way to get the DeviceInfo for the currently used screen (device).
There's a Lupp's Theorem:
"Its mostly easier to guess the right answer tan to find the right question trying to ask the API reference."
For LibreOffice:
https://api.libreoffice.org/docs/idl/re ... eInfo.html and
Code: Select all
devInf = createUnoStruct("com.sun.star.awt.DeviceInfo")
I would suppose that's old and unchanged stuff. It should be the same in AOO from the beginning.
BUT: I did not yet find the (a) way to get the DeviceInfo for the currently used screen (device).
There's a Lupp's Theorem:
"Its mostly easier to guess the right answer tan to find the right question trying to ask the API reference."
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Macro to Select Cell to the Left and Second Macro do Che
Ah yes... that was it...
thisComponent.CurrentController.ComponentWindow.getInfo.PixelPerMeterX
thisComponent.CurrentController.ComponentWindow.getInfo.PixelPerMeterX
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)