Solved

MS VISIO, Set Database Properties of Entity shape programatically

Posted on 2011-09-19
2
1,673 Views
Last Modified: 2012-06-21
Hi Experts,

How can one set Database Properties (add key and non-key columns with data types, etc.) of the Visio ENTITY shape programatically?

Please advise.
0
Comment
Question by:AnwaPeck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
Visio_Guy earned 500 total points
ID: 36560100
Generally, the discipline-specific solutions are closed, with no published APIs or instructions on how to drive them programmatically.

There are, however, a few things to check out.

1. The Page's ShapeSheet. (Turn on Developer mode, right-click the page, choose Show ShapeSheet). Here you'll find a few cells in the User-defined Cells section that you can set programmatically, and that might help you to tweak the document to your liking.

 Database Page ShapeSheet
2. Look at individual Entity shape ShapeSheets. User-defined cells and Actions are interesting places to explore. Looks like you can show or hide various key-related items, but I'm not sure if that's what you need.

3. Look at the object stored in the Document (local) Stencil for the file. This master has a shape that is some sort of COM "bit bucket" that you might be able to tear apart, but I'm not sure if it's really possible. The solution itself reads and writes data to this object.

Probably more questions than answers, but hopefully helps.
0
 

Author Closing Comment

by:AnwaPeck
ID: 36572677
Thank You Visio_Guy!

Regret the delay.

Had to find some time over the past few days to upskill myself so that I could understand and follow the advice given. (Newbie!)  Some notes on the experience:
1. Using the advice given, I could drive out - programmatically - what I needed
2. When inside cell values inside the ShapeSheet window, I hit PF1 (out of sheer desparation) and the exact page of VISIO Help that i needed popped up!
3. The ENTITY shape consists of two 'shapes' (with each having its own shapesheet).  My life become much easier when I stumbled upon that fact.
4. In my solution I generate an ENTITY the way it appears in Visio Professional... without requiring Visio Professional on the user machine!!!

My working solution(again, in VBScript). Would appreciate any feedback:

'VBScript for VISIO
Dim MyApp, MyTemplate, MyPage, MyDoc, MyShpPage, MyShapeChars, _
    MyEntityShape, CurShape, VertPos, HorizPos

'Create new Visio Page Object
Set MyApp = CreateObject("Visio.Application")
Set MyTemplate = MyApp.Documents.Add("dbmodl_m.vst")
For Each MyDoc In MyApp.Documents
  If (MyDoc.Name = "ENTITY_M.VSS") Then
    Set MyStencil = MyDoc
    Exit For
  End If
Next
Set MyDoc = Nothing
Set MyEntityShape = MyStencil.Masters.ItemU("Entity")
Set MyPage = MyApp.ActivePage
Set MyShpPage = MyPage.PageSheet
VertPos = MyShpPage.CellsU("PageWidth").ResultIU / 2
HorizPos = MyShpPage.CellsU("PageHeight").ResultIU - 1

'Drop an entity shape
Set CurrShape = MyPage.Drop(MyEntityShape, VertPos, HorizPos)

'Set character properties & text content of the the header sub-shape
CurShape.Shapes.Item(1).CellsU("Char.Font") = 4
CurShape.Shapes.Item(1).CellsU("Char.Size").Result("pt") = 8
CurShape.Shapes.Item(1).CellsU("Char.Style") = 0
CurShape.Shapes.Item(1).Text = "MYTABLE"

'Set character properties & text content of the the fields sub-shape
CurShape.Shapes.Item(2).CellsU("Char.Font") = 4
CurShape.Shapes.Item(2).CellsU("Char.Size").Result("pt") = 8
CurShape.Shapes.Item(2).CellsU("Char.Style") = 0
CurShape.Shapes.Item(2).Text = "PK" & Chr(9) & "MyKeyFld01" & Chr(10) & _
                                                     "PK" & Chr(9) & "MyKeyFld02" & Chr(10) & _
                                                     "PK" & Chr(9) & "MyKeyFld03" & Chr(10) & _
                                                     Chr(13) & Chr(10) & _
                                                     Chr(9) & "MyField01" & Chr(10) & _
                                                     Chr(9) & "MyField02" & Chr(10) & _
                                                     Chr(9) & "MyField03" & Chr(10) & _
                                                     Chr(9) & "MyField04" & Chr(10) & _
                                                     Chr(9) & "MyField05"

'Bold & underline key fields so that Entity looks (Visio) Professional....
Set MyShapeChars = CurrShape.Shapes.Item(2).Characters
MyShapeChars.Begin = 0
MyShapeChars.End = 3
MyShapeChars.CharProps(2) = 17
MyShapeChars.Begin = 3
MyShapeChars.End = 14
MyShapeChars.CharProps(2) = 21
MyShapeChars.Begin = 14
MyShapeChars.End = 17
MyShapeChars.CharProps(2) = 17
MyShapeChars.Begin = 17
MyShapeChars.End = 28
MyShapeChars.CharProps(2) = 21
MyShapeChars.Begin = 28
MyShapeChars.End = 31
MyShapeChars.CharProps(2) = 17
MyShapeChars.Begin = 31
MyShapeChars.End = 42
MyShapeChars.CharProps(2) = 21

'Insert dividing lines so that Entity looks (Visio) Professional....
CurrShape.Shapes.Item(2).CellsU("User.LineCount") = 9
CurrShape.Shapes.Item(2).CellsU("User.DBHidePKSeperatorLine") = False
CurrShape.Shapes.Item(2).CellsU("User.DBHideTabLine1") = False
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scott A. Helmers Partner, Harvard Computing Group Microsoft Visio MVP Background Microsoft has added more enhancements and new features to Visio 2010 than to any release since they purchased the Visio product line in 2000. In addition, the com…
Book Review: Using Microsoft Visio 2010 by Chris Roth   Disclaimer: The author of Using Visio 2010 is a friend and fellow Visio MVP. Whether you’re new to Visio or are upgrading to Visio 2010 from a previous version, you will find a lot to like…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question