M.Ford
M.Ford

Reputation: 529

Adjust Visio shape properties after placement

I just need some direction, I can find the answer if I know where to look. I am programmatically dropping shapes on a sheet as an output from a db query. Those shapes have a number of properties (prop.). I would like to drop the shape then set those properties to something. The way that I am doing is giving me errors. I suspect that there is a step that I am missing. Here is how I drop the shape

Dim vsoShape As Visio.Shape
Dim vsoMaster As Visio.Master

For lngRow = LBound(lngRowIDs) + 1 To UBound(lngRowIDs) + 1
    varRowData = vsoDataRecordset.GetRowData(lngRow)

    Set vsoMaster = Visio.Documents(varRowData(14) + ".vss").Masters(varRowData(8))

    dblX = dblX + 0.5
    dblY = dblY + 0.5

    Set vsoShape = ActivePage.Drop(vsoMaster, dblX, dblY)

    'vsoShape.Cells("Prop.title").Formula = Chr(34) & varRowData(0) & Chr(34)
    'vsoShape.Cells("Prop.Entitlements").Formula = Chr(34) & varRowData(1) & Chr(34)
    'vsoShape.Cells("Prop.environ").Formula = Chr(34) & varRowData(2) & Chr(34)
    'vsoShape.Cells("Prop.netZone").Formula = Chr(34) & varRowData(3) & Chr(34)
    'vsoShape.Cells("Prop.Mem").Formula = Chr(34) & varRowData(4) & Chr(34)
    'vsoShape.Cells("Prop.vcpu_cores").Formula = Chr(34) & varRowData(5) & Chr(34)
    'vsoShape.Cells("Prop.sockets").Formula = Chr(34) & varRowData(6) & Chr(34)
    'vsoShape.Cells("Prop.hosts").Formula = Chr(34) & varRowData(7) & Chr(34)
    'vsoShape.Cells("Prop.shape").Formula = Chr(34) & varRowData(8) & Chr(34)
    'vsoShape.Cells("Prop.shapeKey").Formula = Chr(34) & varRowData(15) & Chr(34)            
Next lngRow

I think that what I need to do is get some shape ID after I drop it then use that shape id to set the values. The error seems to be that it cannot find the property name. All the prop.X names are correct. The error that I get is

Run-time error '-2032466967 (86db03e9)': Unexpected end of file

I am new to working with Visio VBA. I am more used to Excel.

Michael.

Upvotes: 0

Views: 531

Answers (1)

M.Ford
M.Ford

Reputation: 529

This is not so much of an answer but a solution. For it to be an answer, I would need to know why I was having problems accessing the properties for a group withing a shape when there is more than one group. The solution was to redesign all the custom shapes to only have one group. once that was done, the code as listed above for setting the property values worked without issue.

I suspect the best solution would be to have to figure out how to reference nested group properties directly.

Thanks.

Michael

Upvotes: 0

Related Questions