Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Place shapes in position given by Access database

Status
Not open for further replies.

WhipeOut

MIS
Jan 18, 2008
5
NO
Hi!

I have an Access database containing information about parts. I'd like to have a drawing of this done by Visio 2003.

I've managed to import data from the DB and update "Custom Properties" fields both ways (DB <--> Visio drawing).

My problem is that the shapes is positioned randomly on the page. I have found the parameter that desides the position. It's given in "Size & Position" and displayed by "X" and "Y". I can connect the "PinX" and "PinY" parameters, but I haven't found the ones for "X" and "Y".

How can I connect fields in my DB with the "X" and "Y" parameters?

Can anyone help me change these parameters according to a Access DB?

Thanks

Regards,

Jan-Arve Hansen
 
How are you linking to the database. Is this through code or by an add-on?

John... Visio MVP - Visio.MVPs.org
 
At first I was trying to do it by one of the built-in addons in Visio 2003. First by importing the data from the .mdb file and linking it to the database afterwards using the DB Wizard.

Now I'm trying to do it by VB, but I never work with VB before, so it takes time. :p

If you know how to do it by add-on or similar I'd be very happy.

Thanks.

Jan-Arve
 
Visio comes with VBA, so that may make things easier.

David Edson has some examples in his book on handling Access from Visio using VBA. There are some of the code saples from the book at
To get help with working with PinX, PinY there are examples of woriking with Visio at
John... Visio MVP - Visio.MVPs.org
 
I've found the PinX and PinY parameters, but it's not these who decides where the shape is dropped, or...?

Jan-Arve
 
Pin X and PinY define where the shape is "pinned" to the drawing, so these are the cells you need to play with. If you are dropping the shape, one of the parameters on the Drop method is the Pix and Piny.

Set shpObj = ActivePage.Drop(shp1obj, 4, 5)

This will drop the shape (shp1obj) at 4",5" from the lower left corner. This is assigned to a shape object called shpObj, so you can use shpObj to continue to modify the shape you dropped.

John... Visio MVP - Visio.MVPs.org
 
Hmm.. I've found the parameters and I've discovered that I can assign a value from the database. But if I import the data first, I have to select each of the shapes and select the corresponding database element. That's takes a while.

I guess I'd have to continue the work in VB. I've have used the .drop in the script. Next task is to connect shapes.

I started using a script I found online.

Thank you Visioguy.

Some of the first lines, are the following.
<
Const FlowchartTemplateName$ = "Basic Flowchart.vst"
Const FlowchartStencilName$ = "BASFLO_M.VSS"
Const MasterProcessName$ = "Process"
Const MasterDecisionName$ = "Decision"
>

Since I'm drawing of a network, I'd like to select one or more stencils containing typical network shapes. I've created a stencil that contains all the shapes I need.

Template name: NNN_network.vst
Stencil name: N_Net.vss

But when I define the constants with those names, I get a Run-Time error'91' at the first line I use the constant. The stencil contains the "PC" shape I'm trying to use.

Any suggestions?

Jan-Arve
 
That is from Chris Roth's website. He was one of the original shape developers at Visio.

Those are string constants and are used later in the script, but without the trailing dollar sign.

You should be able to copy the line from the script and add a new stencil
Set docFlowTemplate = Visio.Documents. _
Add(FlowchartTemplateName)
and replacing FlowchartTemplateName with the name of another template. Something like,
Set docFlowTemplate = Visio.Documents. _
Add("Other stencil.vss")


John... Visio MVP - Visio.MVPs.org
 
Thanks John. Now I'm drawing PC shapes. :D

I have a piece of a script for connecting shapes. I'm going to try to solve that one before asking.

But I haven't got anything on editing properties. In the "PC" shape for example, there is alot of properties I don't want to show. Is there a way edit what the "custom properties" displays? I guess I'm able to use the RecSet.fields(#) command to get the data from my DB.

Thanks John.

Jan-Arve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top