I am using Ubuntu 22.04 and LibreOffice 7.6.4.1. I used to download a document generated from a software everyday. The document used to be in English language but its language used to be set as French (France). I want a libreoffice writer macro which will set the language of entire document to either English (India) or English (USA) or English (UK).
In 7.4 I have Tools > Language > For All Text > (Language list)
. Do you not have that?
I know how to set it manually with just few clicks. But some people even don’t know that. I just want to integrate the macro with another macro which we use daily.
Frankly, don’t use macro when there is no compelling need to. If you don’t like Tools
>Language
>…, there are at least 2 other ways:
-
Tools
>Options
,Language Settings
>Languages
and set your default language - modify Default Paragraph Style paragraph style
Font
tab and select Language
Since Dafault Paragraph Style is the ancestor of all other styles, the language setting will cascade to all others (unless, of course, some direct formatting overrides this)
If you’re managing the computer assets in your company, you can also modify the default template to include the language setting and distribute this new default template over all computers. You can do the same with the updated user profile after changing either Tools
>Language
, Tools
>Options
or Default Paragraph Style.
Here is a recorded macro to set all text to English(UK). It works on my v7.4 under Windows. HTH
sub setLang
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 = "Language"
args1(0).Value = "Default_English (UK)"
dispatcher.executeDispatch(document, ".uno:LanguageStatus", "", 0, args1())
end sub