Font Object
Multiple objects Font Multiple objects |
Contains font attributes (font name, font size, color, and so on) for an object.
Using the Font Object
Use the Font property to return the Font object. The following instruction applies bold formatting to the selection.
Selection.Font.Bold = True
The following example formats the first paragraph in the active document as 24point Arial and italic.
Set myRange = ActiveDocument.Paragraphs(1).Range
With myRange.Font
.Bold = True
.Name = "Arial"
.Size = 24
End With
The following example changes the formatting of the Heading 2 style in the active document to Arial and bold.
With ActiveDocument.Styles(wdStyleHeading2).Font
.Name = "Arial"
.Italic = True
End With
Remarks
You can use the New keyword to create a new, stand-alone Font object. The following example creates a Font object, sets some formatting properties, and then applies the Font object to the first paragraph in the active document.
Set myFont = New Font
myFont.Bold = True
myFont.Name = "Arial"
ActiveDocument.Paragraphs(1).Range.Font = myFont
You can also duplicate a Font object by using the Duplicate property. The following example creates a new character style with the character formatting from the selection as well as italic formatting. The formatting of the selection isn't changed.
Set aFont = Selection.Font.Duplicate
aFont.Italic = True
ActiveDocument.Styles.Add(Name:="Italics", _
Type:=wdStyleTypeCharacter).Font = aFont
Properties | AllCaps Property | Animation Property | Application Property | Bold Property | BoldBi Property | Borders Property | Color Property | ColorIndex Property | ColorIndexBi Property | Creator Property | DiacriticColor Property | DisableCharacterSpaceGrid Property | DoubleStrikeThrough Property | Duplicate Property | Emboss Property | EmphasisMark Property | Engrave Property | Hidden Property | Italic Property | ItalicBi Property | Kerning Property | Name Property | NameAscii Property | NameBi Property | NameFarEast Property | NameOther Property | Outline Property | Parent Property | Position Property | Scaling Property | Shading Property | Shadow Property | Size Property | SizeBi Property | SmallCaps Property | Spacing Property | StrikeThrough Property | Subscript Property | Superscript Property | Underline Property | UnderlineColor Property
Methods | Grow Method | Reset Method | SetAsTemplateDefault Method | Shrink Method
Parent Objects | ConditionalStyle Object | Find Object | Font Object | ListLevel Object | Range Object | Replacement Object | Selection Object | Style Object
Child Objects | Borders Object | Font Object | Shading Object