Creating a keyboard shortcut for a specific font

In Impress, I would like to make “Ctrl+T” convert the currently selected text to “Times New Roman” font.

In Tools->Customize, I found only the option of “Font Name”. But when I set Ctrl+T to “Font Name” and click Ctrl+T, I just get the “Font Name” dialogue where I have to manually pick this font each time.

Is there a way to create a shortcut that will automatically change the font to Times New Roman without a dialogue?

As it looks, there is no way with the keys. The question is, what do you want to achieve? Do you want to work fast with changing fonts, or do you just want to set a different font? For the latter, the format templates offer. Please edit your question and write what you want to achieve.

Insert the macro

sub TNR
dim document, dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(4) as new com.sun.star.beans.PropertyValue
args1(0).Name = "CharFontName.StyleName"
args1(0).Value = ""
args1(1).Name = "CharFontName.Pitch"
args1(1).Value = 2
args1(2).Name = "CharFontName.CharSet"
args1(2).Value = 0
args1(3).Name = "CharFontName.Family"
args1(3).Value = 3
args1(4).Name = "CharFontName.FamilyName"
args1(4).Value = "Times New Roman"
dispatcher.executeDispatch(document, ".uno:CharFontName", "", 0, args1())
end Sub

in:

image description

See sequencing in the images:

image description


ATTENTION: If you would like to give more details to your question, use edit in question or add a comment below. Thank you.

If the answer met your need, please click on the ball Descrição da imagem to the left of the answer, to finish the question.

This worked. Thank you so much!

This worked! Thank you so much!
By the way, is it possible to set a specific font size while doing this? I mean I want to change the font to Time New Roman and set the font size to 16pt. How do I do that?

@Surath, just add this add-on to the macro:

dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "FontHeight.Height"
args2(0).Value = 16
args2(1).Name = "FontHeight.Prop"
args2(1).Value = 100
args2(2).Name = "FontHeight.Diff"
args2(2).Value = 0
dispatcher.executeDispatch(document, ".uno:FontHeight", "", 0, args2())

Thank you so much! :slight_smile: