How do I automate links between shapes and database records?

C

CarlOlen

I'm developing an application that links visio shapes to MS-Access database
records. I've created stencils that link to database tables using the
"database wizard." Then, when I drag and drop a stencil onto the diagram, I
can select a record from a pull-down list to link the shape. However, I want
to automate both of these tasks.
1.) How do I automate the setup between a stencil an a database table using
VBA instead of the database wizard?
2.) How do I automate the selection of the linked record when I
automatically drop a shape on the diagram?
 
D

David Parker

The database wizard has several entry points, some of which you can see in
the Actions section of a shape that has been linked manually with it.

Try this VBA sub:

Public Sub EnumDBAddons()
Dim adn As Addon
For Each adn In Visio.Application.Addons
If InStr(adn.Name, "Database") > 0 Then
Debug.Print adn.NameU, adn.Name
End If
Next
End Sub

This should return the following in the Immediate Window:

DBWiz Database Wizard
DBREX Database Re-Export
DBEXP Export to Database...
DBLINK Link to ODBC Database...
DBRS Database Refresh
DBS Database Select Record
DBR Database Refresh Shape
DBU Database Update Record
DBUS Database Update
DBD Database Delete Shape
DBL Database Launch Monitor
DBO Database Settings...
DBEX Database Export Wizard

Here is an example of how you start a particular one in code:

Public Sub SelDB()
Dim adn As Addon
Set adn = Visio.Application.Addons("DBWiz")
adn.Run ""
End Sub

The DB Wizard also creates certain User cells, so you may want to create
these in your code too.
 

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