Bug in DeleteRow for geometry section

N

NAdir

If I want to delete the geometry rows (excluding the first and last) using
the following procedure it works, but if I try to modify a cell in the same
procedure just after modifying the geometry(see REM line), an unexpeceted
behavior happens, If one can try the code and let me know what is the
problem, I will appreaciate :
Sub removePoints(ByVal aShape As Shape)
Dim index As Integer
If aShape.Cells("user.removePoints").Formula = True Then
For index =
aShape.RowCount(VisSectionIndices.visSectionFirstComponent) To 0 Step -1
aShape.DeleteRow VisSectionIndices.visSectionFirstComponent,
VisRowIndices.visRowVertex + index
Next
REM aShape.Cells("user.removePoints").Formula = False
End If
End Sub
I want to keep only the firt and last rows so the line shape will appear
straight. This is same as Visio resetConnector but this is not working.
 
J

JuneTheSecond

Try next.
Sub removePoints(ByVal aShape As Shape)
Dim index As Integer, N As Integer
If aShape.Cells("user.removePoints").Formula = True Then
N = aShape.RowCount(VisSectionIndices.visSectionFirstComponent)
For index = N - 2 To 2 Step -1
aShape.DeleteRow VisSectionIndices.visSectionFirstComponent, index
Next index
aShape.Cells("user.removePoints").Formula = False
End If
End Sub
 
J

JuneTheSecond

Would you please tell me more what happened.
Is your lines are in the section Geometry1?
Is it not grouped?
Because my example is working to the simple shape of 7 lines Geometry1,
if LocCalcWH is set to 1 or 0.
 
N

NAdir

Yest LocCalcWH is set to 0. I think the line that causes the problems is :
aShape.Cells("user.removePoints").Formula = False
I call this instruction just after I change the geometry when I comment it,
the procedure works fine, when not the line becomes transparent. Here is the
situation : I have a line used like a connector between shapes with a context
menu to reset it. When the user chooses to reset the line it becomes straight
horizontal with only 2 vertices (begin and end). This is why I want to remove
the geometry. Now I found a workaround: I just delete the shape and then
create a new straight one but I dont know why the geometry deletion does not
work. Thank you
 
J

JuneTheSecond

Of course, my example does not work if
aShape.Cells("user.removePoints").Formula = False
, so please change to true to make sure it works.
 

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