Code to read the active cells format

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Fraz627
Posts: 22
Joined: Sat Jun 17, 2017 8:31 am

Code to read the active cells format

Post by Fraz627 »

Pretty new at Open office and I've tryed searching the web but find no clear anwsers.
How does one go about reading the cells format such as color, patterns, numberic, text or date/time

Thanks
Open Office 4.1 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Code to read the active cells format

Post by Zizi64 »

How does one go about reading the cells format such as color, patterns, numberic, text or date/time
What you want to read really: the name of the applied cell style, the propreties of the applied style or the direct formatting properties of the cells?

You can get the name of the applied style by a cell formula based on a macro code (it will not work with the stylename applied by the conditional format feature):
viewtopic.php?f=21&t=2762
viewtopic.php?t=27574

...or directly by a macro code:

Code: Select all

Dim sTyle as String
Dim oCell as Object
...
REM You must get the cell object here: the actually selected one or you can get a cpecific cell by its coordinates or by its reference/name
...
sStylename = oCell.CellStyle
https://www.openoffice.org/api/docs/com ... Style.html

And you can get/modify the properties of a specific cell:
viewtopic.php?f=25&t=41387


Tip:
Install the MRI or the XrayTool to examine programming object in your macro code.
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
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Code to read the active cells format

Post by Villeroy »

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Fraz627
Posts: 22
Joined: Sat Jun 17, 2017 8:31 am

Re: Code to read the active cells format

Post by Fraz627 »

Thanks I'm still learning
Open Office 4.1 on Windows 10
Post Reply