[Workaround] Change default highlighting color

Discuss the word processor
Post Reply
AntonSamokat
Posts: 6
Joined: Sun Mar 17, 2024 2:39 pm

[Workaround] Change default highlighting color

Post by AntonSamokat »

I'm using dark scheme for the documents. Text highlighted (marked) with default yellow color is badly seen. How to change default color to, for example, orange and save (persist) it? In such a way that after reopening (closing and opening) a document highlighting color was not reset to default yellow.

As work around it is possible to create two custom styles: one with orange background, another one without any settings at all to clear orange background. But this approach is not convenient because:
  • Second style does not revert highlighting, but applies custom style. It is not the same as remove normal highlighting marks.
  • Custom styles need to be carried manually from one document to others.
Last edited by MrProgrammer on Tue Apr 30, 2024 9:17 pm, edited 1 time in total.
Reason: Tagged ✓ [Workaround] -- MrProgrammer, forum moderator
Open Office 4.1.13 on Ubuntu 20.04
AntonSamokat
Posts: 6
Joined: Sun Mar 17, 2024 2:39 pm

Re: How to change default highlighting color Writer?

Post by AntonSamokat »

Seems that it is not possible now - https://ask.libreoffice.org/t/how-to-ch ... iter/21996

So work around with custom styles must be used.
Open Office 4.1.13 on Ubuntu 20.04
JeJe
Volunteer
Posts: 2797
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to change default highlighting color Writer?

Post by JeJe »

Are you using LibreOffice or OpenOffice. That LibreOffice thread is old, it now has an expert configuration where a lot of values can be set but I don't know enough to know whether that is one of them

Another way is with a macro. The attached document has one (mostly made with the macro recorder) to set the color on the document opening event for that document.

You could put the same macro in your installation macros and set the document opening and new document events to run it so it works with all documents.
Attachments
Orange highlight.odt
(10.43 KiB) Downloaded 13 times
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
AntonSamokat
Posts: 6
Joined: Sun Mar 17, 2024 2:39 pm

Re: [Workaround] Change default highlighting color

Post by AntonSamokat »

Now I'm using OpenOffice 4.1.13. But I will also interested in solution for Libre Office.

Thank you for the macro.

I have several questions:
- How to apply this macro? (macros are new for me in the office but I will investigate)
- How to set up Office to apply this macro automatically when the document is opened?
- Am I right that macro needs to be imported to each document file?
- How to get color code to set in macro based on office color panel picker in UI? Here ( https://ask.libreoffice.org/t/macro-hig ... iter/31655 ) I found that for this test macro can be recorded with pressing the button with needed color. But this is not convenient. Is it possible to specify color in this macro as RGB code? (It must be simpler to get - viewtopic.php?t=71672 )

By now with the help of test macro recording I found out the following codes for orange color shades:
Orange color (more orange):
16737792

Orange 1 color (more yellow):
16763904

---

I extracted macro from "Orange highlight.odt" attachment:

Code: Select all

sub SetOrangeBackColor
if thiscomponent.ImplementationName = "SwXTextDocument" then
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "BackColor"
args1(0).Value = 16763904

dispatcher.executeDispatch(document, ".uno:BackColor", "", 0, args1())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Escape", "", 0, Array())
end if
end sub
Open Office 4.1.13 on Ubuntu 20.04
JeJe
Volunteer
Posts: 2797
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Workaround] Change default highlighting color

Post by JeJe »

You can change the line to this for an RGB color (mid grey in the below example):

Code: Select all

args1(0).Value = rgb(125,125,125)
You don't need to have the macro in every document. You just need to copy and paste it to the Standard library of your installation rather than that of the document. See how to install a code snippet here:

viewtopic.php?t=5519

If within the document I posted you go to Tools menu/customize/Events tab you can see that the Open Document event is set to that macro within the document.

Once you've put the macro in your installation you need to make a change there:

Select "Save in Openoffice" instead of save in the document.

Then click on the Open Document event to select it and then click the macro button and find where you put the macro in your installation (instead of in the document and assign that macro to the event for all documents opening.)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply