DB Question

A

Arash Ferdowsi

Hi,
I have several shapes on a document that link to a database. I can right
click on a shape and click 'select database record' which causes the shape to
point to a different record. Is there any way to automate this through use of
a macro? Thanks a lot.
 
D

David Parker [Visio MVP]

This actually runs the addon "DBS"
How do you want to automate it?
The DB Wizard includes an option to layout all records from a Table/View
 
A

Arash Ferdowsi

Hi David,
In my program I have a layout of cubes and have an add cube button. As of
now, the macro I wrote makes a copy of a current cube, pastes it on the
appropriate page, and then changes the name of the cube. Now all I need is
for the cube to point to the appropriate cube number (which is the primary
key). I could have the user right click and click on change record, but I'd
rather this be automated. Thanks a lot!
 
C

Chris Roth [ Visio MVP ]

Your code copies a shape, which leaves it selected in the window. At this
point, you could probably run the add-on to get the dialog to pop-up. There
are two ways to do this:

In the shape, set the cell:

Events.EventDrop = RunAddon("DBS")

Every time a shape is dropped or duplicated, the add-on will run.

Or, have your code call:

Visio.Application.Add-ons("DBS").Run("")

the ("") is some dummy argument, perhaps parameters for the add-on. I don't
remember off hand.

--

Hope this helps,

Chris Roth
Visio MVP
 
A

Arash Ferdowsi

Hi Chris,
Is there any place I can access an object library / resource on the visio
database addon? I'm not sure how to go about figuring out parameters/methods
without guessing them. Thanks.
 
C

Chris Roth [ Visio MVP ]

no documentation I know of. The way we do it is to look at the shapes it
creates and try to figure out what it all means. Look for User cells and
Actions cells in the ShapeSheet. RUNADDON or RUNADDWARGS functions are also
things to look for.

Happy hunting, wish I had more info for you.

--

Hope this helps,

Chris Roth
Visio MVP
 
A

Arash Ferdowsi

At this point I have =RunAddOnWArgs("DBS", "/Record= 200")

I've also tried /Primary_Key among other arguments. Do you guys have any
guesses as to what argument would point my shape to record 200? Thanks again.
 
D

David Parker [Visio MVP]

I would set the key custom property values in code, then use RUNADDON("DBR")
myself...
 
A

Arash Ferdowsi

Hi David,
I'm not sure what custom property you're referring to. There are no key
custom property I know of for shapes linked to a database. I'm fairly sure
that RunAddOnWArgs for DBR should take an argument that references the key,
however, I'm not sure what the argument is. Thanks again.
 
D

David Parker [Visio MVP]

If you look at the User cells created by the DB Wizard addon then you should
see which are the "key" properties, i.e those that are used for linking to
fields in the DB. You just need to update the key properties then run DBR.
BTW, which version of Visio are you using?
 

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