Visio Guy

Visio Discussions => Programming & Code => Topic started by: Hamwic on November 09, 2015, 09:58:42 AM

Title: Counting Shape Data Fields (Rows)
Post by: Hamwic on November 09, 2015, 09:58:42 AM
I'm trying to write a little routine that will need to count the number of data fields/rows contained in a shape. The fields have named (EmployeeName, Band, StartDate,EndDate etc.) rather than having "Row_0", "Row_1", "Row_2" etc..

The field (Row) names can change depending on the shape, so cannot hard code the name in. What I was thinking is writing a loop and adding one on ech pass so that I can lookup the row number, i.e.

Sub Counting_Fields

vsoShape As Visio.Shape
Dim intCount as Integer
Dim strPropRow as String

IntCount = 0

        For Each vsoShape In vsoPage.Shapes
            intPropRow = vsoShape.Cells("prop.Row_" & intCount)
            intCount = intCount + 1
       Next

End Sub

As Row_0 is actually named as Employeename, I cannot use the above syntax. I need to find a way of counting each row without using the field name.

p.s. intCount will be used elsewhere, I cut the whole routine down just to include whjat I thought was relevant

Thanks in advance!
Title: Re: Counting Shape Data Fields (Rows)
Post by: Paul Herber on November 09, 2015, 10:06:42 AM
(this is Delphi/FreePascal syntax but the idea should be the same.)


rows := shpObj.RowCount[visSectionProp]

Title: Re: Counting Shape Data Fields (Rows)
Post by: Hamwic on November 09, 2015, 10:23:32 AM
Thanks Paul!! That helped massively!
Title: Re: Counting Shape Data Fields (Rows)
Post by: Paul Herber on November 09, 2015, 10:25:19 AM
:-)
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 55 (show)
Files included: 25 - 925KB. (show)
Memory used: 747KB.
Tokens: post-login.
Cache hits: 8: 0.00113s for 22,303 bytes (show)
Cache misses: 1: (show)
Queries used: 11.

[Show Queries]