Newcomer needs guidance

M

Mike C.

I would be appreciative if someone could steer me towards a resource that
would give me specific instruction and guidance on the usage of the Visio
2003 ActiveX control and Type Library within the Visual Basic 6.0
environment.

I have scoured the MSDN and the Visio 2003 SDK and though there is a lot of
good information within these resources, I have yet to find basic and
elementary examples on how to develop certain animation techniques and
methods. I'm even having difficulty referencing a specific shape within my
drawing as I don't know the approach that one should take. Should I loop
through the Shapes collection or do I use the Shapesheet to change the
shapes properties, etc? How do you do this? I have many many questions. Any
help would be appreciated.

Regards,
Mike C.
 
A

Al Edlund

As a newcomer (just learning) I found it easiest to learn to handle Visio
using the embedded VBA support first. That way your not in the continual
mode of trying to handle events using AddAdvise and since the code executes
in the Visio address space it runs quicker. After you get comfortable
handling objects and shape sheets then you can consider moving to the
activex control and vb6.

For the nuts and bolts at a beginners level you can go to :
http://msdn.microsoft.com/library/en-us/devref/HTML/DVS_Copyright_1270.asp?frame=true

If you want the 'bible' you should get a copy of Graham Widemans "Visio 2003
Developer's Survival Pack"

Al
 
M

Mike C.

Thanks Al,

Obtaining Grahams book is already on my "to do" list as I've seen it
mentioned in several locations, since my posting this morning. Although I've
made some progress since this morning, I can't say that any of this
Automation business is intuitive. Case in point; A simple object i.e..
rectangle or ellipse, is referred to as a Sheet (
Drawing1.vsd:page-1:Sheet.4 <SHAPE> ). It has taken me the better part of
the day figuring out the name of the blasted thing. Now that I know how to
change the name to something that makes sense, via Format/Special/Name
property... I can at least identify the object in VB code and manipulate
its' Cell properties. I know that somebody, somewhere, had their reasons for
naming a geometric object as a Sheet, but to the casual onlooker, a Sheet is
generally thought of as a page or blank canvas. This really threw me off
course. If anyone wants to chime in on this point, I'm "all ears". Now, I do
realize as time goes on, I will eventually adapt to this new environment and
it will become second nature to me. But in the meantime, this is painful.

I appreciate your suggestion on utilizing VBA as a primer during my
introduction, but inevitably everything has to be ported over to VB. I'm
already into the TypeLib and the ActiveX, and things are coming along,
albeit slowly. So I believe that I will continue in that fashion.

Regards,

Mike C.
 
M

Mark Nelson [MS]

Do not rename your shapes and refer to them as something other than
Sheet.xxx. This will work for simple cases, but you will at some point
cross the line where shape names do not work, and you will be stumped.

Shapes are called sheets because they are blank canvases, so you intuited
the reference properly. The geometry of the shape is what is drawn on that
canvas. It is better to think of the shape's geometry as being drawn on the
shape canvas rather than on the page canvas. When you create formulas that
define the geometry of the shape, they all are based on the shape's local
coordinate system, not the page coordinate system.

My best advice to a newcomer to Visio automation is to recognize that Visio
is a lot deeper and also more complicated than it appears to be on the
surface. A big reason why is that in order to successfully program with
Visio, you must first learn how to make and manipulate Visio shapes. When
Visio used to provide its own developer training course, we spent the first
three out of five days not programming. 60% of the course was dedicated to
shapes and the Shapesheet. That made the programming portion of the course
more sensible and easier to understand overall.
 
M

Mike C.

Mark,

Thank you very much for the advice. Having dabbled with Visio, off and on,
over the years, I have come to respect the fact that it is an extremely
powerful tool. Now that I have an application that demands much more than
just a simple flow chart, I'm getting a feel for what you've described. I
believe a trip to the local book store is in order and I'll take your
suggestion to heart.

In the particular application that I'm working on, I'm required to represent
a factory floor process. Knowing that Visual Basic does not intrinsically
facilitate animated graphics, I considered that Visio would be an
appropriate tool to represent the process. With respect to your comment on
the re-naming of sheets, or better said, your objection to the renaming, and
the type of application that I have at hand, how would I relate to the
different objects without having some sort of cross reference? It's easier
to understand what Tank1 is vs. Sheet.1. I'm sure that I could "map" to the
various sheets with process related VB object variable names, but just
curious how you would approach this concept.

Thanks,

Mike C.
 
M

Mark Nelson [MS]

Hi Mike,

I think I understand what you are trying to do now. Let's say you have
created a drawing with various equipment shapes in it. These were created
from Master shapes like Tank, Pump, Valve, etc. Now you want to initialize
your VB code by assigning the first tank shape to your first VB tank object
and the second tank shape to your second VB tank object. For this you can
use the regular shape name as in Shapes.Item("Tank.1") or
Shapes.Item("Tank.2") to find the shape on the drawing page and get an
object reference to it.

However, if you wanted to add a water level shape to the drawing that varied
its size based on the fluid volume in your tank shape, you would need to use
the Sheet.nnn reference when constructing a formula to place in the water
level's shapesheet. You might do something like this:
Shapes.Item("Level.1").Cells("Height").Formula = "=Sheet.1!Prop.WaterLevel"
You cannot use Tank.1 in place of Sheet.1 here.

If you are thinking about using Visio as a process control panel or
graphical reporting tool, you're in good company. This is a common use of
Visio and automation. However, Visio does not have built-in support
animation. I believe that there is some sample code with Graham Wideman's
book that shows how simple animation can be done though.

--
Mark Nelson
Microsoft Corporation

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

Mike C.

Mark, I do believe that you've got it! It makes a whole lot more sense to me
now. And yes, I am prepared for VB to "drive" the animation.

Thanks for your time. I'm sure I'll be recognized as a frequent poster, as
this project moves on.

Have a great weekend,

Mike C.
 
M

Michael

Mike C. said:
Thanks Al,

Obtaining Grahams book is already on my "to do" list as I've seen it
mentioned in several locations, since my posting this morning. Although I've
made some progress since this morning, I can't say that any of this
Automation business is intuitive. Case in point; A simple object i.e..
rectangle or ellipse, is referred to as a Sheet (
Drawing1.vsd:page-1:Sheet.4 <SHAPE> ). It has taken me the better part of
the day figuring out the name of the blasted thing. Now that I know how to
change the name to something that makes sense, via Format/Special/Name
property... I can at least identify the object in VB code and manipulate
its' Cell properties. I know that somebody, somewhere, had their reasons for
naming a geometric object as a Sheet, but to the casual onlooker, a Sheet is
generally thought of as a page or blank canvas. This really threw me off
course. If anyone wants to chime in on this point, I'm "all ears". Now, I do
realize as time goes on, I will eventually adapt to this new environment and
it will become second nature to me. But in the meantime, this is painful.

I appreciate your suggestion on utilizing VBA as a primer during my
introduction, but inevitably everything has to be ported over to VB. I'm
already into the TypeLib and the ActiveX, and things are coming along,
albeit slowly. So I believe that I will continue in that fashion.
From a Visio perspective I may be a couple of months (maybe weeks :-((( )
in front of you... I dug through Grahams books as well and now feel
reasonably
comfortable with what I am trying to achieve.
Do look at the VBA as you can interactively or 'debug' your automation.
Porting from VBA to VB (in my case?) wasn't more then copy/paste when
finished
and change some of the initial references ...

Wish I was better a VB, but coming along reasonable...

as a recent newcomer I can definately ' endorse' the VBA option and
ofcourse Grahams books (nice size aswell :))) )

Michael
 
M

Mike C.

Thanks for the insight there, Michael. I ordered the book early Monday
morning. I was a bit surprised to see that the publisher uses the "print on
demand" method of manufacturing and distributing their books. I wasn't aware
that such a thing existed. It may save trees, but it extends the delivery
time.

I live and breath in the VB world, so that's why I feel more comfortable
there. As soon as time permits, I'll be migrating up to VB.Net... but, after
my initial look at the stuff, it may be a good time to retire. I'll keep the
idea of exercising VBA, close at hand if I should run into any sticky
situations. It all boils down to deadlines. If I had the time, I'd
thoroughly explore Visio and all it's features <sigh>.

Anyway, thanks again,

Mike C.
 

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