Expand Row under VBA control

R

RichardC

Hi.
I am using Visio to import a file and then VBA to export the vertices of the
shapes. I had some problems and discovered that some shapes were defined as
polyline in the geometry section and others were expanded. I have managed to
get the code to open the shapesheet and locate the pointer at polyline cell
but I am having trouble getting the right mouse click menu to open under
program control. I have been surprised that this is not just a function call
or method of a cell object. I can find no reference to it in the help file
and a macro recording of the action seems to indicate that I have to
calculate and input all the x and y information myself. I tried sendkeys (I
only need a kludge to automate the process at the moment. :=>) and the
suggested keystrokes don't open the menu for me. maybe it is my keyboard
file or something. Anyway thanks for reading this far, and if anyone has a
snippet that shows how to automate this function I would be grateful.

Best Regards

RichardC
 
M

Mark Nelson [MS]

Use Shape.CellsSRC( ).Formula to retrieve the contents of any cell,
including geometry cells. If the contents of the cell is a polyline, then
you would parse the formula to extract the individual items.
 
D

David Parker

If I understand correctly, you want to get the X/Y co-ords of each vertex.
If so, then you can walk thru' each row in the geometry sections in VBA,
test the row type, and extract the X/Y. You do not need to open the
ShapeSheet at all.

Be aware that a shape can have multiple geometry sections, so you will have
to loop thru' from first to last (they are called visSectionFirstComponent
and visSectionLastComponent confusingly).

You will need to parse the PolyLine formula to get your X/Y co-ordinates
Anyhow, here is a start:

Public Sub ReadV()
Dim iRow As Integer
Dim iSect As Integer
Dim shp As Visio.Shape

Set shp = Visio.ActiveWindow.Selection.PrimaryItem

For iSect = Visio.visSectionFirstComponent To
Visio.visSectionLastComponent
If shp.SectionExists(iSect, Visio.visExistsAnywhere) = True Then
For iRow = 1 To shp.RowCount(iSect)
Select Case shp.RowType(iSect, iRow)
Case Visio.VisRowTags.visTagMoveTo
Debug.Print shp.CellsSRC(iSect, iRow,
Visio.visX).ResultIU, shp.CellsSRC(iSect, iRow, Visio.visY).ResultIU
Case Visio.VisRowTags.visTagLineTo
Debug.Print shp.CellsSRC(iSect, iRow,
Visio.visX).ResultIU, shp.CellsSRC(iSect, iRow, Visio.visY).ResultIU
Case Visio.VisRowTags.visTagPolylineTo
Debug.Print shp.CellsSRC(iSect, iRow,
Visio.visPolylineData).Formula
End Select

Next iRow
Else
Exit For
End If
Next iSect

End Sub
 
R

RichardC

Mark/David

Thanks for the responses.
I was just hoping to be able to get them all in the same format. ie with the
polyline expanded.
However parsing the polyline entry does make sense, I guess I was just
fixating on making my solution work rather than solving the problem.

Thanks guys.

RichardC
 

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