Error when setting Shape.Item to UniqueID, and shape does exist

G

goldnhue

(Visio 2007 with Vista)
I am storing Visio shape information in a database using the Shape's
"UniqueID" field as the unique identifier. As part of my VBA sync routine,
I cycle through the database and check for a Visio Shape that has each
UniqueID. If none exists, Visio generates an error which I trap so I'll know
which records to delete. This works great EXCEPT it sometimes generates an
error even when the shape does exist, and I cannot isolate why! The error
(-2032465756) is repeatable consistently on the same shapes, but I can't
isolate what is different about those shapes to cause the error. Any
suggestions? What should I be checking for?

Here is codes snippet:

' For each record, check for a related activity box
Do While Not objRS.EOF
UnID = objRS("UniqueID")
Set shpObj = Visio.ActivePage.Shapes.Item(UnID)
' If there is no Visio shape with this UnID, it will
generate an
' error which I trap then resume next

objRS.movenext
Loop

Thank you in advance,
Gina
 
P

Paul Herber

(Visio 2007 with Vista)
I am storing Visio shape information in a database using the Shape's
"UniqueID" field as the unique identifier. As part of my VBA sync routine,
I cycle through the database and check for a Visio Shape that has each
UniqueID. If none exists, Visio generates an error which I trap so I'll know
which records to delete. This works great EXCEPT it sometimes generates an
error even when the shape does exist, and I cannot isolate why! The error
(-2032465756) is repeatable consistently on the same shapes, but I can't
isolate what is different about those shapes to cause the error. Any
suggestions? What should I be checking for?

Here is codes snippet:

' For each record, check for a related activity box
Do While Not objRS.EOF
UnID = objRS("UniqueID")
Set shpObj = Visio.ActivePage.Shapes.Item(UnID)
' If there is no Visio shape with this UnID, it will
generate an
' error which I trap then resume next

objRS.movenext
Loop

Thank you in advance,
Gina

How are objRS and UnID defined?
Is the uniqueID field large enough in the database?
What is the value of the UniqueID that fails?
 
G

goldnhue

Column size is 40. The IDs are read into the database programmatically.
(i.e., VBA cycles through all objects on the page and grabs the information).


I even tried copying and pasting the UniqueID directly into my code from the
Visio shape to test as follows, but I still get Err.Number=-2032465756
I.e.,
UnID = "{8B04B9D7-353F-4DD5-93F5-5A10C2BD7752}"
Set shpObj = Visio.ActivePage.Shapes.Item(UnID)
 
P

Paul Herber

Column size is 40. The IDs are read into the database programmatically.
(i.e., VBA cycles through all objects on the page and grabs the information).


I even tried copying and pasting the UniqueID directly into my code from the
Visio shape to test as follows, but I still get Err.Number=-2032465756
I.e.,
UnID = "{8B04B9D7-353F-4DD5-93F5-5A10C2BD7752}"
Set shpObj = Visio.ActivePage.Shapes.Item(UnID)

I'll suggest double-checking that the uniqueID is correct.
I have a utility that will display all the UniqueIDs on a page, see in
my sig below.
 
G

goldnhue

Found it ... Thank you Paul! I was so focused on the "Set" code, that I did
not think to check the code where I was grabbing the IDs in the first place,
and that was the the source of myproblem.

Thanks again for pointing me the right direction!
 

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