2

Excel ファイルのグラフ内のすべての図形をループしたいと考えています。これは原則として

Dim currChart As Chart
Set currChart = Sheets("Diagramm 1")

Dim sShapes As Shape
For Each sShapes In currChart.Shapes

        Debug.Print sShapes.name
        Debug.Print sShapes.TextFrame.Characters.Text

Next sShapes

ただし、プロパティTextFrameはすべてのタイプの形状で認識されるわけではありません。したがって、シェイプにテキストフレームがあるかどうかをテストしたいと思います。どうやってやるの?

4

1 に答える 1

6

シェイプ オブジェクト内にテキストがあるかどうかを知る必要があると想定しました。したがって、このコードをループ内に配置してみてくださいFor...Next:

Debug.Print sShapes.Name
'to check if there is textframe
'but mostly there is
If Not sShapes.TextFrame Is Nothing Then

    'to check if there is text within textframe
    If sShapes.TextFrame2.HasText Then

        Debug.Print sShapes.TextFrame.Characters.Text
    End If
End If

それがあなたが探しているものであることを願っています。

于 2013-04-23T16:42:50.653 に答える