How to create ShapeExist function?

K

Kathy

Hi everyone,
My client created a lot of drawing files (more than 20000 files)
programatically. Because of the errors in the codes there are many shapes
that are referencing custom properties in the other shapes that does not
exist.
I need to fix this by scanning the shapes, checking if the shapes they are
pointing exists, and delete the reference if they don't exist. I first
tried to use CellExist for the referenced shapes, but I hit the error,
because I was trying to access execute the CellExist for the shapes that
don't exist.

I am using VBA...how I can tell that the shape, for example Sheet.X does not
exist in the file?

Thanks!
 
J

JuneTheSecond

My idea is using keyword nothing, like;
On Error Resume Next
strNameId = "sheet.1"
Set shp = ActivePage.Shapes(strNameId)
If shp Is Nothing Then
MsgBox strNameId & " not exists."
Else
MsgBox strNameId & " exists."
End If
 
C

Chris Roth [ Visio MVP ]

You can check for what's called a REF() error - which occurs when a cell is
missing. The syntax looks like this:

Shape.Cells("User.x").Error = visio.visErrorReference

Where visio.visErrorReference = 55. There are a bunch of other cell errors
like DIV0 as well.


--

Hope this helps,

Chris Roth
Visio MVP
 
Top