title | ms.service | ms.assetid | ms.date | ms.localizationpriority |
---|---|---|---|---|
Shapes.AddTextbox method (Project) |
project-server |
ee8c619f-8b35-6f94-e680-86dbeedd6d19 |
06/08/2017 |
medium |
Adds a text box to the report, and returns a Shape object that represents the new text box.
expression. AddTextbox
(Orientation, Left, Top, Width, Height)
expression A variable that represents a Shapes object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
Orientation | Required | MsoTextOrientation | The orientation of the text box. Some constants may not be available, depending on the language that is installed. |
Left | Required | Single | The position, in points, of the left edge of the text box. |
Top | Required | Single | The position, in points, of the top edge of the text box. |
Width | Required | Single | The width, in points, of the text box. |
Height | Required | Single | The height, in points, of the text box. |
Orientation | Required | MSOTEXTORIENTATION | |
Left | Required | FLOAT | |
Top | Required | FLOAT | |
Width | Required | FLOAT | |
Height | Required | FLOAT | |
Name | Required/Optional | Data type | Description |
Shape
The following example adds a text box with a light yellow background and a visible border. The text string is formatted and manipulated by using members of the TextFrame2 object.
Sub AddTextBoxShape()
Dim theReport As Report
Dim textShape As shape
Dim reportName As String
reportName = "Textbox report"
Set theReport = ActiveProject.Reports.Add(reportName)
Set textShape = theReport.Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 50, 300, 100)
textShape.TextFrame2.TextRange.Characters.Text = "This is a test. It's only a test. " _
& "If it had been real information, there would be some real text here."
textShape.TextFrame2.TextRange.Characters(1, 15).ParagraphFormat.FirstLineIndent = 10
textShape.TextFrame2.TextRange.Characters(16).InsertBefore vbCrLf
' Set the font for the first 15 characters to dark blue bold.
With textShape.TextFrame2.TextRange.Characters(1, 15).Font
.Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent5
.Fill.Solid
.Fill.Visible = msoTrue
.Size = 14
.Bold = msoTrue
End With
With textShape.Fill
.ForeColor.RGB = RGB(255, 255, 160)
.Visible = msoTrue
End With
With textShape.Line
.Weight = 1
.Visible = msoTrue
End With
End Sub
Shapes Object Shape Object TextFrame2 Property MsoTextOrientation Enumeration (Office)
[!includeSupport and feedback]