Intecepting Font & Font Size dropdowns from the 'Formatting Toolba

T

Tim

I am putting together a template where I want to restrict the font to Arial
and the font size from 8 to 11 point. How can I intercept the dropdowns
located on the standard 'Formatting Toolbar'?
 
K

Klaus Linke

Tim said:
I am putting together a template where I want to restrict
the font to Arial and the font size from 8 to 11 point.
How can I intercept the dropdowns located on the standard
'Formatting Toolbar'?


Hi Tim,

If you don't want the users to change the font, you can just remove the
font control in your template.
I'd do the same for the font size dropdown, and offer some styles with
"Arial" and the desired sizes.

If that is not an option:
Intercepting the font size control wouldn't do much good, since you can't
remove items from the dropdown's list, as far as I know.

You would need to create your own dropdown:

' run once to create the new font size dropdown:
Dim myCBDrop As CommandBarControl
Set myCBDrop =
CommandBars("Formatting").Controls.Add(Type:=msoControlDropdown)
With myCBDrop
.Caption = "Font Size"
.TooltipText = "Font Size"
.DescriptionText = "Changes" & _
"the font size of the selection"
.AddItem "8"
.AddItem "9"
.AddItem "11"
.OnAction = "SetFontSize"
End With

Sub SetFontSize()
Selection.Font.Size = _
CommandBars.ActionControl.Text
End Sub

I haven't tested this much. Perhaps you may find it necessary to write more
code (for example so that Ctrl+Shift+P sets the focus on the new control,
as it did with the built-in control).

Regards,
Klaus
 
K

Klaus Linke

BTW, the original "font size" dropdown is a combo box.
I made the replacement a dropdown so you can't type in a font size.

And you may want to add error handlers to the "SetFontSize" macro ... say,
for when a user tries to apply a font size to a shape.

Regards,
Klaus
 
T

Tim

Klaus,

Thanks for the help.
I have already started trying to replace the style, font, and font size
controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top