Populating Custom Props From A Shapes Text Field

D

Dennis G

I am trying to populate some of the custom properties of all the shapes on
a layer through a loop. The shapes are telecom shapes and I have modified
their shapesheets so the text fields will resize automatically. Each shapes
text field will represent a wiring closet number, a patch panel in the WC
and the port number of the patch panel where the data port is terminated.
For ex: 23:B:01 would indicate the port is terminated at Port 1 of Patch
Panel B in wiring closet 23.
I can write the VB end to get the loop to parse the text. I need to
determine where to access the Visio properties to deliver the text to the
custom props fields.
Here's the code from a test form I have created using a button to execute a
macro. I am getting undeclared object errors:

Private Sub CommandButton1_Click()

Dim page As Visio.page
Dim shp As Visio.Shape
Dim shps As Visio.Shapes
Dim Layer As Visio.Layer
Dim C As Integer
Set page = ActivePage

For Each shp In page.Shapes
For C = 1 To shp.LayerCount
If shp.Layer(C) = "PORT" Then
shp.Layer(C).Cells(prop.Prop1.Value) = "test"

End If

Next C

Next
End Sub

Thanks for any help,
Dennis
 
A

Al Edlund

I'd try something like this

Dim visPage As Visio.page
Dim visShp As Visio.Shape
Dim visShps As Visio.Shapes
Dim visLayer As Visio.Layer
Dim viscell As Visio.cell
Dim A As Integer
Dim C As Integer

Set visPage = Visio.ActivePage
For A = 1 To visPage.Shapes.Count
Set visShp = visPage.Shapes(A)

For C = 1 To visShp.LayerCount
If visShp.Layer(C).Name = "Port" Then
If visShp.CellExists("prop.prop1", False) Then
Set viscell = shp.Cells("prop.Prop1")
viscell.Value = "test"
End If
End If
Next C
Next A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top