[Solved] Calc cell: Characters property from Excel

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

[Solved] Calc cell: Characters property from Excel

Post by eeigor »

Help me find an analog of Excel range property:
Property Characters ([Start], [Length]) As Characters

in order to change the color of individual characters with a macro.
Last edited by MrProgrammer on Sat Jan 23, 2021 10:05 pm, edited 4 times in total.
Reason: Tagged ✓ [Solved]
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calc cell characters

Post by Villeroy »

The cell supports interface com.sun.star.text.XTextRange as shown by the MRI extension.
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
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

Re: Calc cell characters

Post by eeigor »

Need a usage example. I can't figure out how to find and extract the substring.
@Villeroy, please show me how to work with the getText(), getStart(), and getEnd() methods. Read-only. And setString().
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calc cell characters

Post by Villeroy »

I don't know. If I ever had to do that (luckily I don't have to), I would start MRI and read
https://wiki.openoffice.org/wiki/Docume ... _Documents
https://wiki.openoffice.org/wiki/Docume ... _Documents
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
User avatar
Lupp
Volunteer
Posts: 3552
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Calc cell: Characters property from Excel

Post by Lupp »

This is only a relic of the original thread. The subject was changed, and most of the posts vanished.
Now the thread is tagged SOLVED despite the fact that there is no solution.

There couldn't be a solution in the full sense since a property delivering the information asked for doesn't exist.

However, the deleted posts contained two workarounds: One by Villeroy using a Python script, and one by myself using the Calc function REGEX() available in LibreOffice V 6.2.0 or higher calling it in a macro via FunctionAccess. Both these workarounds were restricted to cases where the findings of a search (which actually were the ranges the question mentioned) did not include (parts of) the string-representation of a TextField.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
MrProgrammer
Moderator
Posts: 4906
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: [Solved] Calc cell: Characters property from Excel

Post by MrProgrammer »

Lupp wrote:This is only a relic of the original thread. The subject was changed, and most of the posts vanished.
The topic was split because the OP asked a second question (about RegEx) after the original one was solved. Forum policy is one subject per topic. The later posts, including those you mentioned, are in Does LO have a RegEx object?
Lupp wrote:Now the thread is tagged SOLVED despite the fact that there is no solution.
The split topic says the original question was solved:
eeigor, indicating topic was solved wrote:With that it is more or less clear.
Unfortunately the forum software does not allow a user's post to be split in the middle of it. I would have preferred for that sentence to remain with the original topic and the split topic to begin with the next "Another question …" sentence. But this isn't possible, nor is it possible to duplicate the post so I can put one in each topic. I suppose I could put that in my own post, but forum moderation is enough work when user's don't start new topics appropriately.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

Re: [Solved] Calc cell: Characters property from Excel

Post by eeigor »

I'll be more careful in the future.
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Solved] Calc cell: Characters property from Excel

Post by Zizi64 »

Here is a sample file that show you how to colorize letters individually by a macro in a Calc Cell (created and tested in LibreOffice):
Gradient color.ods
(22.88 KiB) Downloaded 153 times
viewtopic.php?f=7&t=77844
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.
eeigor
Posts: 214
Joined: Sun Apr 12, 2020 10:56 pm

Re: [Solved] Calc cell: Characters property from Excel

Post by eeigor »

Looks mesmerizing...
Ubuntu 18.04 LTS • LibreOffice 7.5.3.2 Community
Post Reply