Método Shapes.AddTextbox (Project)

Adiciona uma caixa de texto ao relatório e retorna um objeto Shape que representa a nova caixa de texto.

Sintaxe

expression. AddTextbox(Orientação,esquerda,superior,largura,altura)

expressão Uma variável que representa um objeto Formas.

Parâmetros

Nome Obrigatório/Opcional Tipo de dados Descrição
Orientation Obrigatório MsoTextOrientation A orientação da caixa de texto. Algumas constantes podem não estar disponíveis, dependendo do idioma instalado.
Left Obrigatório Single A posição, em pontos, da borda esquerda da caixa de texto.
Top Obrigatório Single A posição, em pontos, da borda superior da caixa de texto.
Width Obrigatório Single A largura, em pontos, da caixa de texto.
Height Obrigatório Single A altura, em pontos, da caixa de texto.
Orientation Obrigatório MSOTEXTORIENTATION
Left Obrigatório FLOAT
Top Obrigatório FLOAT
Width Obrigatório FLOAT
Height Obrigatório FLOAT
Nome Obrigatório/Opcional Tipo de dados Descrição

Valor de retorno

Formato

Exemplo

O exemplo a seguir adiciona uma caixa de texto com um fundo amarelo claro e uma borda visível. A cadeia de caracteres de texto é formatada e manipulada usando membros do objeto TextFrame2 .

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

Confira também

Shapes ObjectShape ObjectTextFrame2 PropertyMsoTextOrientation Enumeration (Office)

Suporte e comentários

Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.