[Solved] Change text colour inside a macro
[Solved] Change text colour inside a macro
I am trying to write 4 simple macros, one each to insert a Club, diamond, heart and spade symbol and to ensure that club and spade symbols show as black while heart and diamond symbols show as red.
I recorded the macros by Tools>Macros>Record macro, inserting the special character, setting the font colour and highlighting the character then stopping recording. This works when I run the macro as the character appears in the correct colour. However, the colour change doesn't stop with the character. Any subsequent characters continue in red or black. So, could someone please tell me how do I set the colour back to whatever it was? I could add a space following the symbol and set that to Automatic, but I don't always want a space following the character.
Thanks
Tony
I recorded the macros by Tools>Macros>Record macro, inserting the special character, setting the font colour and highlighting the character then stopping recording. This works when I run the macro as the character appears in the correct colour. However, the colour change doesn't stop with the character. Any subsequent characters continue in red or black. So, could someone please tell me how do I set the colour back to whatever it was? I could add a space following the symbol and set that to Automatic, but I don't always want a space following the character.
Thanks
Tony
Last edited by MrProgrammer on Sat Aug 08, 2020 3:26 am, edited 2 times in total.
Reason: Added ✓ icon
Reason: Added ✓ icon
Open Office 4.1.5
Windows 10 Home
Windows 10 Home
Re: Change text colour inside a macro
Where you want to insert the colorized characters? Into a Writer document? Into a Cals spreadsheet?
The recorded macros never will be so efficient. Write your macros (vased on the API functions) instead of the recording.
If it is a Writer document, then you can apply a user-defined Character style to the inserted character - by the macro.
The Character style feature not exist in the Spreadsheet documents.
Please upload your macro here.
The recorded macros never will be so efficient. Write your macros (vased on the API functions) instead of the recording.
If it is a Writer document, then you can apply a user-defined Character style to the inserted character - by the macro.
The Character style feature not exist in the Spreadsheet documents.
Please upload your macro here.
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.
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.
Re: Change text colour inside a macro
How to colorize characters in a Calc cell by API functions:
https://forum-test.openoffice.org/en/fo ... 45&t=97884
https://forum-test.openoffice.org/en/fo ... 45&t=97884
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.
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.
Re: Change text colour inside a macro
I want the macros to operate in both a Writer document and a Presentation.
I am writing documentation and lessons for contract bridge and need to be able to enter the symbols as efficiently as possible.
Thanks
Tony
I am writing documentation and lessons for contract bridge and need to be able to enter the symbols as efficiently as possible.
Thanks
Tony
Open Office 4.1.5
Windows 10 Home
Windows 10 Home
Re: Change text colour inside a macro
And you can use the Autocorrect function with colorized character (unchecking the "Text only" parameter of the function).
In this case you not need any user defined macros.
for example:
Replace -> With
*D -> ♦
*H -> ♥
The Autocorrect function has a new feature in the LibreOffice: you can insert characters by the AutoCorrect without before/after spaces of the "Replace" code
In this case you not need any user defined macros.
for example:
Replace -> With
*D -> ♦
*H -> ♥
The Autocorrect function has a new feature in the LibreOffice: you can insert characters by the AutoCorrect without before/after spaces of the "Replace" 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.
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.
Re: Change text colour inside a macro
Thank you, that would be a much better approach. However, the Text Only checkbox is ticked and greyed out, so I can't untick it. I can only get the symbols in black.
While I am here, could you please advise how I can set my default language for everything to English (Australia). I can change it on the fly, but it keeps reverting to English (USA).
While I am here, could you please advise how I can set my default language for everything to English (Australia). I can change it on the fly, but it keeps reverting to English (USA).
Open Office 4.1.5
Windows 10 Home
Windows 10 Home
Re: Change text colour inside a macro
It works for me in my LibreOffice, when I put a formatted character from the Writer into the "With" box of the Autocorrect function. The pasted character still black in the "With" box, but it has a color property, and the function will insert a colorized character.However, the Text Only checkbox is ticked and greyed out, so I can't untick it. I can only get the symbols in black.
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.
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.
Re: Change text colour inside a macro
Tools menu/Options/Language Settings for setting the default
Would Autotext work here for what you want to do?
Select each colored character with the following text set the automatic again and create your autotext from those (edit menu/autotext)
Would Autotext work here for what you want to do?
Select each colored character with the following text set the automatic again and create your autotext from those (edit menu/autotext)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Change text colour inside a macro
I've tried, in autocorrect, to replace !H with the heart symbol. It appears in the autocorrect list but when I type !H it doesn't convert, it just appears as !H. I guess I'm missing a "Switch autocorrect on" setting, but I can't find it.
It's getting late here now, so I'll have another look in the morning.
Thanks for all your help so far.
Tony
It's getting late here now, so I'll have another look in the morning.
Thanks for all your help so far.
Tony
Open Office 4.1.5
Windows 10 Home
Windows 10 Home
Re: Change text colour inside a macro
1) You should have your autocorrect setting such that autocorrection is enabled when typing; Tools | Autocorrect Options and select the Options tab; see the highlighted section in the image. You may also want the option to replace while modifying existing text.
2) You need to type the shortcut followed by a space for the autocorrect to happen.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: Change text colour inside a macro
Additional information:I've tried, in autocorrect, to replace !H with the heart symbol. It appears in the autocorrect list but when I type !H it doesn't convert, it just appears as !H. I guess I'm missing a "Switch autocorrect on" setting, but I can't find it.
The function only work properly in the Apache OpenOffice, when the code seems as a standalone word:
Code: Select all
{paragraph beginning}!H{space}
{space}!H{space}
{space}!H{sentence end character}
{space}!H{line end mark}
{space}!H{paragraph end mark}
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.
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.
- MrProgrammer
- Moderator
- Posts: 4907
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Change text colour inside a macro
Here is a similar topic, with a non-macro solution for Writer.TonyRolfe wrote:I am trying to write 4 simple macros, one each to insert a Club, diamond, heart and spade symbol and to ensure that club and spade symbols show as black while heart and diamond symbols show as red.
Creating Card Suit Symbol Shortcuts in OpenOffice For Bridge
For Impress, perhaps one should create the text in Writer and paste into the presentation.
Of course. This is how text works in OpenOffice.TonyRolfe wrote:I recorded the macros by Tools>Macros>Record macro, inserting the special character, setting the font colour and highlighting the character then stopping recording. This works when I run the macro as the character appears in the correct colour. However, the colour change doesn't stop with the character. Any subsequent characters continue in red or black.
Thin spaceTonyRolfe wrote:I could add a space following the symbol and set that to Automatic, but I don't always want a space following the character.
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
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).
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).
Re: Change text colour inside a macro
The thin space idea sounds good. However, I can't see how to add one in Writer. I've tried the unicode 2009 (Ctrl-Shift-u2009) but that doesn't do anything. I've also tried various combinations of ctrl, shift, alt space, but they all seem to do other things. I've looked at the various options in Insert > special Character but can't find the thin space character
I'm running Windows 10, if that is relevant.
I'm running Windows 10, if that is relevant.
Open Office 4.1.5
Windows 10 Home
Windows 10 Home
Re: Change text colour inside a macro
This will insert a red diamond where the caret is and the following text will be black so long as its typed straight afterwards.
Code: Select all
Sub RedDiamond
vc = thiscomponent.currentcontroller.viewcursor
vc.string = "♦"
vc.charcolor = rgb(255,0,0)
vc.collapsetoend
vc.charcolor = 0
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
- MrProgrammer
- Moderator
- Posts: 4907
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Change text colour inside a macro
From the Insert → Special Character dialog you will find the suits in the Miscellaneous Symbols subset. Clicking the heart, for example, puts it in the list of characters. Then in the General punctuation subset clicking the thin space (U+2009) adds it to the list of characters. It is hard to tell which of the spacing characters in the row is the thin space, however it is the one above the Euro sign. If you click the wrong spacing character (not U+2009) in the dialog by mistake, you should start over since it will be added to the list where it is invisible. After adding both characters to the list, the OK button inserts them in the text document. Then you can format just the heart with a red font and create your AutoText. The thin space will still have the Automatic font color so characters following your AutoText do not take the red font. You won't need an evil macro, just standard Writer features. It is best to use standard features so you are not dependent on others to create macros for you.TonyRolfe wrote:I've looked at the various options in Insert > special Character but can't find the thin space character
Once created, the AutoText is available in any document. Just type the shortcut and press F3. Read about AutoText in Help → Index or in User Guides (PDF) or searching for topics about it in the Writer Forum.
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
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).
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).
Re: [Solved]Change text colour inside a macro
Many thanks to all who replied. I now have a number of ways to do this. I've added [Solved] to the header.
Tony
Tony
Open Office 4.1.5
Windows 10 Home
Windows 10 Home