2013-04-23 2 views
1

Excel의 차트에있는 모든 모양을 반복하고 싶습니다. 이 그러나, 재산 TextFrame이 모양의 모든 유형에 의해 알 수없는vba : 모양에 텍스트 프레임이 포함되어 있는지 테스트합니다.

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 

에 원칙적으로 작동합니다. 따라서 도형에 텍스트 프레임이 있는지 테스트하고 싶습니다. 어떻게해야합니까?

답변

3

모양 개체 내에 텍스트가 있는지 알아야한다고 가정했습니다. 따라서 루프 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 

을 나는 그것이 당신을 위해 무엇을 찾고 있습니다 바랍니다.

+0

좋은 +1입니다. :) –