How To Determine Visio Shape Type in VBA

G

Gary

Is there a way using VBA to determine if a shape is an ellipse, rectangle,
line, etc...

I have an application that draws a chart based on data in a MS Access
database. The user then may add text or other items to make the information
more usable. I want to be able to save these add items to a database and
redraw them automatically if the chart gets redrawn. This way the user only
has to manually add these items once.

Thanks

Gary
 
G

Gary

This doesn't work. When you draw an item using the drawing tools the shape
dosen't have a Master object.

Gary
 
M

Mark Nelson [MS]

The main problem that you face is that shapes created by the different
drawing tools do not have different types. They all create a masterless
shape. Only the geometry varies.

Because all these shapes are essentially the same, I'm not sure why you need
to differentiate them. If your goal is to recreate the shapes, you need to
record the geometry and then restore the geometry. If you are doing this
through automation, I suggest working with the Curve and Path objects in
Visio. Another option is to get the drawing in XML form and save the pieces
you need. Neither approach will be simple though.
 
G

Gary

I was hoping that if I drew an object using the elliptical tool or the
rectangle tool or line tool, etc... that there might be a tag somewhere in
the shape that would indicate the type of shape it is. Are you saying that I
could create a rectangle and then by applying the various geometry lines I
could change the look of of the object. Say from a rectangle to an ellipse?

Gary
 
J

junethesecond

When ellipse is drawn, the tag is recorded
as the name of row in geometry section
of shape sheet, and this row name is
readable, but can not be got by VBA.
Error occurs when name property is used.
i think there are needs to get such
properties, because you naturally wish
to know "there are three ellipses on the
page", though there may be no way
other than to use xml format, now.
 
J

junethesecond

RowType property may be help to get the kind of shape.
IType = shp.RowType(visSectionFirstComponent, 1)
returns 143, if shp is an ellips.
143 is visTagEllipse, member of VisRowTags.
 
M

Mark Nelson [MS]

Yes, that is what I mean. You could use the DrawRectangle command to make a
basic shape that matches the width and height of the shape you stored. Then
by modifying the geometry of the basic shape, you could replicate the actual
shape stored. This is helpful since it is possible to create more kinds of
shapes than just rectangles, circles and ellipses. What about a triangle,
or home plate, or a shape with some rounded sides and some straight sides?
You don't care how complex the geometry is. You just have to scan it from
the original shape, store it and reconstruct it.

I do wonder about the overall approach you are taking here though. It seems
that your goal of storing drawings in a database prevents users from truly
customizing their drawing. Any change they wish to make is subject to you
writing code to round-trip the information through the database. Why not
actually store the drawing documents generated by the database and
customized by the user? I'm not sure why refreshing an existing drawing is
much different than creating a new drawing from scratch. Overall it seems
like refreshing drawings would take less code than scanning, storing and
reconstructing.

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Gary

Let me see if I can explain what I am actually doing. I work for an
Insurance Broker. One of the applications I have created takes insurance
policy data that has been entered via an Access application and turn it into
a visual representation of the client’s insurance coverage where the X axis
is time and the Y axis is dollars of coverage. Do this in and of itself was
a challenge because it is like fitting a jigsaw puzzle together in code.
After the chart it drawn the consultant may want to add some custom tags to
the chart. If for some reason the chart needs to be redrawn (usually because
of policy information changes) then the custom tags will be deleted before
the chart if redrawn. What I am trying to do is to capture to the database
information about these custom tags so the consultant doesn’t have to
recreate them from scratch again. They will just be able to select from a
list which of the custom tags they want inserted back into the chart.

I hope this makes sense.

Gary
 
Joined
Feb 20, 2013
Messages
1
Reaction score
0
Where to find the RowType enumerations

I had a hard time finding these...
I can't post links, but the Visio VisRowTags Enumeration are at
  • msdn.
  • microsoft.
  • com/
  • en-us/
  • library/
  • office/
  • ff765852.aspx
 

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