Author Topic: visExistsAnywhere versus visExistsLocally  (Read 133 times)

0 Members and 1 Guest are viewing this topic.

OldSchool1948

  • Jr. Member
  • **
  • Posts: 67
visExistsAnywhere versus visExistsLocally
« on: October 21, 2020, 07:55:59 AM »
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. 
Code
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. 
Code
iRow = vsoShape.AddNamedRow(visSectionProp, C_SHPSHT_ROW_SHAPE_VER_NUM, visTagDefault)
I always use visExistsAnywhere. Could that be the problem?



wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: visExistsAnywhere versus visExistsLocally
« Reply #1 on: October 21, 2020, 03:52:56 PM »
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

  • Jr. Member
  • **
  • Posts: 67
Re: visExistsAnywhere versus visExistsLocally
« Reply #2 on: October 22, 2020, 10:13:31 AM »
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