Visio - How do I automate links between shapes and database records?

Asked By CarlOle on 29-May-08 08:07 AM
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
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?
--
Carl Olen


David Parker replied on 29-May-08 09:31 AM
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.


--
David Parker
Microsoft MVP (Visio)
http://bvisual.spaces.live.com
http://www.visualizinginformation.com
David Wilson replied to David Parker on 15-Feb-12 02:24 PM
What ar ethe parameters to the Wizard that can be used in VBA?



Dave