Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Gets the formatting properties for the font of the specified text. Read-only.
Syntax
expression.Fill
expression An expression that returns a Font2 object.
Example
The following code assumes that a shape has been inserted into Sheet1. The code inserts text into the shape and changes the fore color of the font to bold and red. It then adds a carriage return after the second word, creating a second paragraph, and aligns the paragraph to the right.
Sub TestShapeAttributes()
Dim shp As Excel.Shape
Dim rng As Office.TextRange2
Dim rngWord As Office.TextRange2
Dim rngRun As Office.TextRange2
Dim rngPara As Office.TextRange2
Dim fnt As Office.Font2
Set shp = ActiveSheet.Shapes(1)
Set rng = shp.TextFrame2.TextRange
rng.Text = "This is test text."
Set rngWord = rng.Words(2)
Set fnt = rngWord.Font
With fnt
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Bold = msoTrue
End With
Set rngRun = rng.Runs(3)
rngRun.InsertBefore vbCr
Set rngPara = rng.Paragraphs(2)
rngPara.ParagraphFormat.Alignment = msoAlignRight
End Sub
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.