Name
shape
.TextFrame
Synopsis
For autoshapes, returns the TextFrame
object used to set and format text appearing on the shape. Causes an error for most other shape types. The following code draws an oval and adds some text to it:
Sub DrawOval( ) Dim ws As Worksheet, s As Shape Set ws = ActiveSheet ' Draw a shape Set s = ws.Shapes.AddShape(msoShapeOval, 60, 30, 1, 1) ' Add text. s.TextFrame.Characters.text = "Vigorous writing is concise." ' Resize shape to fit text. s.TextFrame.AutoSize = True End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.