Font2.Fill Property (Office)

Gets the formatting properties for the font of the specified text. Read-only


expression. Fill

expression An expression that returns a Font2 object.


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

Font2 Object

Font2 Object Members