ControlCollection.GetInlineShapeForControl(Control) Método

Definição

Obtém o InlineShape subjacente para o controle especificado.

public Microsoft.Office.Interop.Word.InlineShape GetInlineShapeForControl (System.Windows.Forms.Control control);

Parâmetros

control
Control

O controle na instância ControlCollection da qual você deseja obter o InlineShape.

Retornos

InlineShape

O InlineShape subjacente para o controle especificado.

Exemplos

O exemplo de código a seguir adiciona um Button ao documento para que seu estilo de disposição seja embutido em texto. Em seguida, o código chama o GetInlineShapeForControl método para obter o local do controle de seu subjacente InlineShape .

private void WordGetInlineShape()
{
    Microsoft.Office.Tools.Word.Controls.Button testButton =
        this.Controls.AddButton(this.Paragraphs[1].Range, 50, 25,
        "testButton");

    Microsoft.Office.Interop.Word.InlineShape buttonShape =
        this.Controls.GetInlineShapeForControl(testButton);

    if (buttonShape != null)
    {
        MessageBox.Show("The following properties can be cached in the" +
            "\n" + "document to enable you to recreate the control:"
            + "\n\n" + "Range: position " + buttonShape.Range.Start.
            ToString() + "through " + buttonShape.Range.End.ToString()
            + "\n" + "Width: " + buttonShape.Width.ToString() + "\n" +
            "Height: " + buttonShape.Height.ToString());
    }
}
Private Sub WordGetInlineShape()
    Dim testButton As Microsoft.Office.Tools.Word.Controls.Button = _
        Me.Controls.AddButton(Me.Paragraphs(1).Range, 50, 25, "testButton")

    Dim buttonShape As Microsoft.Office.Interop.Word.InlineShape = _
            Me.Controls.GetInlineShapeForControl(testButton)

    If buttonShape IsNot Nothing Then
        MessageBox.Show("The following properties can be cached in the" & _
            vbCrLf & "document to enable you to recreate the control:" _
            & vbCrLf & vbCrLf & "Range: position " & _
            buttonShape.Range.Start.ToString _
            & " through " & buttonShape.Range.End.ToString _
            & vbCrLf & "Width: " & buttonShape.Width.ToString _
            & vbCrLf & "Height: " & buttonShape.Height.ToString)
    End If
End Sub

Comentários

Se o estilo de disposição do controle não estiver definido como alinhado com o texto, o GetInlineShapeForControl método retornará null .

Aplica-se a