automatic font selection in macro

Good morning
I have another strange question.
Work related I have to insert not infrequently symbols into texts.
To make work easier, I have already created a number of macros to insert for example the symbol "micro" into a text using a keyboard shortcut.

Problem:
Let's say, I created the macro in a document that happened to use "Arial" as font and later want to use it in a document that uses "Times Roman". The macro I created then inserts an "Arial font micro" into the Times Roman text, which then looks out of place.

Is there a trick to create macros, so that the inserted symbol matches the surrounding font?
I have tried all sorts of things, but could not yet find a solution.
It is not really a "problem", but such an automatic font adjustment would be nice/helpful.

Thank you.
Thomas

if I wrote a macro that inserts the letter 'X', I would not expect the insertion to specify the font unless I went out of my way to do so.

I am interested in seeing the macro that you are using.

I'm not able right now to try to find a macro that would do what you want, but if you can't find one let me know, and I will see if I can provide one for you after I look at the macro you are using now.

Understand, however, the next two days for me will be hit or miss on availability.

⁣Sent from BlueMail ​

if I wrote a macro that inserts the letter 'X', I would not expect the insertion to specify the font unless I went out of my way to do so.

I am interested in seeing the macro that you are using.

Well, I am not actually "writing" the macro - I have no idea how to do that.
I use "Tools -> Macros -> Record macro" and open the "insert special characters dialog box".
THIS is where the problem is.
As far as I can tell, there is no way NOT to select a font in that dialog.
On top you have the "Search / Font / Subset" fields.
"Font" gives you a list of fonts, but not the choice of "none / automatic" etc. - or allows you to delete the currently selected font.
I had been hoping to find that kind of choice.

Mr. Pitonyak. Please don't worry. I am not in a hurry. I have been pondering this for years already ...

Thank you.
Thomas Blasejewicz

Addition

if I wrote a macro that inserts the letter 'X', I would not expect the insertion to specify the font unless I went out of my way to do so.

* Japanese font -> I was just playing around and this is NOT what I want.
This is what LibreOffice has recorded:

sub insertalpha
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(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Symbols"
args1(0).Value = "α"
args1(1).Name = "FontName"
args1(1).Value = "MS Pゴシック"

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

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, Array())

end sub

I would have used a text cursor, but, the recorded Macro is trivially modified to remove the font name, you just need to know that you can do that :slight_smile:

sub insertAlphaNoFont
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 = "Symbols"
args1(0).Value = "α"

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

end Sub

Lot easier than another solution (if you really did need the font name), which would look at the text cursor and pull the current font and use that. Inserting text at a text cursor (view cursor) should also not have needed a font.

if I wrote a macro that inserts the letter 'X', I would not expect the
insertion to specify the font unless I went out of my way to do so.

I am interested in seeing the macro that you are using.

Well, I am not actually "writing" the macro - I have no idea how to do
that.
I use "Tools -> Macros -> Record macro" and open the "insert special
characters dialog box".
THIS is where the problem is.
As far as I can tell, there is no way NOT to select a font in that dialog.
On top you have the "Search / Font / Subset" fields.
"Font" gives you a list of fonts, but not the choice of "none /
automatic" etc. - or allows you to delete the currently selected font.
I had been hoping to find that kind of choice.

Mr. Pitonyak. Please don't worry. I am not in a hurry. I have been
pondering this for years already ...

Thank you.
Thomas Blasejewicz

I created a bug report after reading above.

is here: https://bugs.documentfoundation.org/show_bug.cgi?id=123527

it seems that 'automatic font selection in macro' works as i would expect. The character inserted seems to be of choosen font, and the font choosen before entering the 'insert/special character' screen is set back.

But there seems to be (a small) bug in selecting the correct character from the 'insert/special character' screen.