Create ERD, Add Entities & Relationships using VBA

B

BigJ

I have spent the past 4-5 hours trawling Google web & groups in vain,
looking for info. I want to do the following in VBA in Visio 2003
Professional:

1. Create a new ER diagram
2. Create two entities
3. Add some fields to each entity, specifying basic details (data
type, required, primary key)
3. Create a relationship between the two entities

I can do these things manually in my version of Visio 2003
Professional (i.e. in the UI), but I need to automate the procedure. I
would have thought this should be basic and universal!

PLEASE, could someone assist? Also, can anyone suggest a reference
that covers this topic in detail?
 
S

Serge

I saw this example on site "http://visio.mvps.org/VBA.htm"

Dropping a Master: This subroutine will drop a master on the page.

You need to get a Master or Shape object to drop on the page before calling
the Drop method. The example below drops the Circle shape from the Blocks
Raised stencil on the current drawing page.
Public Sub TestDropShape()
Dim stencil As Visio.Document, mstCircle As Visio.Master
Set stencil = ThisDocument.Application.Documents.Open("Blocks Raised.vss")
ThisDocument.Application.Windows(ThisDocument.Index).Activate
Set the ActiveWindow to the drawing window.
Set mstCircle = stencil.Masters("Circle") ' Get the master named "Circle"
and drop that shape on the page!
ThisDocument.Pages(1).Drop mstCircle, 1, 3 ' Drop the shape, mstCircle, at
location X=1 Y=3
End Sub
 
B

Barb Way

While you can drop any master using this code sample, it will not allow the
automation of the DB modeling solution. There is no public API to allow
the creation of Relationships and other DB modeling properties, which are
not exposed in the ShapeSheet.

Barb Way
Product Support - Visio
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Thread-Topic: Create ERD, Add Entities & Relationships using VBA
thread-index: Acgb355r9FTn8GoXR4SdztSMQRqktw==
X-WBNR-Posting-Host: 207.46.19.168
From: =?Utf-8?B?U2VyZ2U=?= <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: RE: Create ERD, Add Entities & Relationships using VBA
Date: Wed, 31 Oct 2007 10:01:02 -0700
Lines: 20
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2992
Newsgroups:
microsoft.public.visio.createshapes,microsoft.public.visio.database.modeling
Path: TK2MSFTNGHUB02.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.visio.database.modeling:90
microsoft.public.visio.createshapes:109
NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
X-Tomcat-NG: microsoft.public.visio.database.modeling

I saw this example on site "http://visio.mvps.org/VBA.htm"

Dropping a Master: This subroutine will drop a master on the page.

You need to get a Master or Shape object to drop on the page before calling
the Drop method. The example below drops the Circle shape from the Blocks
Raised stencil on the current drawing page.
Public Sub TestDropShape()
Dim stencil As Visio.Document, mstCircle As Visio.Master
Set stencil = ThisDocument.Application.Documents.Open("Blocks Raised.vss")
ThisDocument.Application.Windows(ThisDocument.Index).Activate
Set the ActiveWindow to the drawing window.
Set mstCircle = stencil.Masters("Circle") ' Get the master named "Circle"
and drop that shape on the page!
ThisDocument.Pages(1).Drop mstCircle, 1, 3 ' Drop the shape, mstCircle, at
location X=1 Y=3
End Sub
 

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