visExistsAnywhere versus visExistsLocally

Started by OldSchool1948, October 21, 2020, 12:55:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

OldSchool1948

I've been using the following code logic for a very long time to get the row index for a shape.  This logic is used hundreds and hundreds of times in my application.  If the shape data row doesn't exist, I create the row and the ID; if it does exist, I get the ID. 
Dim iRow As Integer
If Not vsoShape.CellExists(C_PROP & C_SHPSHT_ROW_SHAPE_VER_NUM, visExistsAnywhere) Then
    iRow = vsoShape.AddNamedRow(visSectionProp, C_SHPSHT_ROW_SHAPE_VER_NUM, visTagDefault)
Else
    iRow = vsoShape.CellsRowIndex(C_PROP & C_SHPSHT_ROW_SHAPE_VER_NUM)
End If

vsoShape.CellsSRC(visSectionProp, iRow, _
   visCustPropsValue).formula = C_QT & getStencilVersionNumber() & C_QT

Lately, on some shapes, the code crashes on the "AddNamedRow" line. 
iRow = vsoShape.AddNamedRow(visSectionProp, C_SHPSHT_ROW_SHAPE_VER_NUM, visTagDefault)
I always use visExistsAnywhere. Could that be the problem?



wapperdude

Have you tried to see if there's a bad variable assignment?  Since you know where the error occurs, stop execution before that line.  Use mouse over to check values to see if they're correct.  If you have drawing window and code window side by side, you ought to be able to see which shape is the current target.  You can open shapesheet and check it.  Leave shapesheet open, use <f8> key to step thru code and watch what goes into shapesheet.

Be the detective!  😁
Visio 2019 Pro

OldSchool1948

After doing some research, I found the error had nothing to do with visExistsAnywhere.  Long story short, I created custom incoming and outgoing off-page reference shapes from Visio's default shape.  I removed the ability for users to change directions, and I added a dropdown allowing users to select the target page.  When the target page is selected, the hyperlink to that page is created.

I also have a "Patching Tool" that updates an older file to match the most current template file.  When patching an older file, the crash happens on a select few of off-page reference shapes.  In those cases, the Hyperlinks SubAddress is set to "=PAGENAME()."  Where it works, the SubAddress references an existing page by name.  This I can fix.  (Prior versions did not have the dropdown - another long story  :D)

wapperdude, thanks for trying to help.  You've always been very helpful - and I truly appreciate it.

Regards,

Johnnie