Share via


Shape.GeometryCount プロパティ (Visio)

図形の [Geometry] セクションの数を返します。 読み取り専用です。

構文

GeometryCount

Shape オブジェクトを表す変数。

戻り値

整数

この Microsoft Visual Basic for Applications (VBA) マクロは、GeometryCount プロパティを使用して、図形にある [Geometry] セクションの数を判断します。

このマクロを実行するには、まず、リスト ボックスを含むユーザー フォームをプロジェクトに挿入します。 フォームとリスト ボックスの名前には既定の名前をそのまま使用します。 [プロパティ] ウィンドウで、フォームの幅を 400、リスト ボックスの幅を 300 に設定します。 また、このマクロは、アクティブなページに 1 つまたは複数の図形が存在することも前提としています。

Public Sub GeometryCount_Example() 
 Dim vsoShape As Visio.Shape 
 Dim intCurrentGeometrySection As Integer 
 Dim intCurrentGeometrySectionIndex As Integer 
 Dim intRows As Integer 
 Dim intCells As Integer 
 Dim intCurrentRow As Integer 
 Dim intCurrentCell As Integer 
 Dim intSections As Integer 
 
 'Get the first shape from the active page. 
 Set vsoShape = ActivePage.Shapes(1) 
 
 'Clear the list box. 
 UserForm1.ListBox1.Clear 
 
 'Get the count of Geometry sections in the shape. 
 '(If the shape is a group, this will be 0.) 
 intSections = vsoShape.GeometryCount 
 
 'Iterate through all Geometry sections for the shape. 
 'Because we are adding the current Geometry section index to 
 'the constant visSectionFirstComponent, we must start with 0. 
 For intCurrentGeometrySectionIndex = 0 To intSections - 1 
 
 'Set a variable to use when accessing the current 
 'Geometry section. 
 intCurrentGeometrySection = visSectionFirstComponent + intCurrentGeometrySectionIndex 
 
 'Get the count of rows in the current Geometry section. 
 intRows = vsoShape.RowCount(intCurrentGeometrySection) 
 
 'Loop through the rows. The count is zero-based. 
 For intCurrentRow = 0 To (intRows - 1) 
 
 'Get the count of cells in the current row. 
 intCells = vsoShape.RowsCellCount(intCurrentGeometrySection, intCurrentRow) 
 
 'Loop through the cells. Again, this is zero-based. 
 For intCurrentCell = 0 To (intCells - 1) 
 
 'Get the cell's formula and 
 'add it to the list box. 
 UserForm1.ListBox1.AddItem _ 
 vsoShape.CellsSRC(intCurrentGeometrySection, intCurrentRow, _ 
 intCurrentCell).LocalName & ": " & _ 
 vsoShape.CellsSRC(intCurrentGeometrySection, intCurrentRow, _ 
 intCurrentCell).Formula 
 Next intCurrentCell 
 Next intCurrentRow 
 Next intCurrentGeometrySectionIndex 
 
 'Display the user form. 
 
 UserForm1.Show 
 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。