Open Visio and create Shapes from Table

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Your program versions would always be useful information. For Visio 2007, did you try Ribbon > Data>Display Data on Shapes then from popup 'Data Grahphics' panel, New Data Graphic & go through dialogs to pick the source information? You can control the placement and formatting of the text and shape attributes once you get the data in.
 
Upvote 0
Hey,

I got Access 2013.

I can do what you described. But what I want to do is following:

I want a button on my form in Access. When I click this button, I want that a new Visio Opens and Drops one shape for every record in my table. The Shape's text should be the value of the record in my table.

So it's the same as in the thread I postet (one of the last posts), but with Access and not with Excel.

Thanks for helping me out here!

Best Regards
Fabian
 
Upvote 0
Hey Folks,

I got it!

Private Sub btn_OpenVisio_Click()
Dim rs As DAO.Recordset
Dim AppVisio As Object
Dim vsoCharacters1 As Visio.Characters
Dim lX As Long
Dim dXPos As Double
Dim dYPos As Double
Dim shapetext As String
Dim i As Integer

Const visSectionCharacter = 3
Const visCharacterSize = 7
i = 1

Set rs = CurrentDb.OpenRecordset("Select * FROM tbl_Application")

Set AppVisio = CreateObject("visio.application")
AppVisio.Visible = True

AppVisio.Documents.AddEx "", visMSDefault, 0 'Open Blank Visio Document
AppVisio.Documents.OpenEx "basic_u.vss", visOpenRO + visOpenDocked 'Add Basic Stencil

dXPos = 0
dYPos = 10

rs.MoveFirst

Do While Not rs.EOF
AppVisio.Windows.ItemEx(1).Activate
AppVisio.ActiveWindow.Page.Drop AppVisio.Documents.Item("BASIC_U.VSS").Masters.ItemU("Square"), dXPos, dYPos

Set vsoCharacters1 = AppVisio.ActiveWindow.Page.Shapes.ItemFromID(i).Characters
vsoCharacters1.Begin = 0
vsoCharacters1.End = 100

vsoCharacters1.Text = CStr(rs![Application_ID].Value) & vbCrLf & CStr(rs![Application Name].Value)

AppVisio.ActiveWindow.Page.Shapes.ItemFromID(i).CellsSRC(visSectionCharacter, 0, visCharacterSize).FormulaU = "20 pt"

dXPos = dXPos + 2
If dXPos Mod 10 = 0 Then
dYPos = dYPos - 2
dXPos = 0
End If
i = i + 1
rs.MoveNext
Loop

End Sub


Now in the next step I want not to take a normal "Square" Shape in Visio, but my own created DataShape.
Is it possible to do the same with a DataShape and writing the data of each record in the ShapeData?

Thanks,

Raicoon
 
Upvote 0
Can you post what type library references are required for this? I only have a visio reader library, so I must be missing something, but will guess at the answer anyway.
I suspect you would have to create your own stencil (rather than monkey with one of the built in stencils), add your created shape to it, and reference your stencil in code instead of the standard stencil. Replace all instances of basic_u.vss with your stencil name, but also consider the hierarchy of a stencil properties or methods - "Masters.ItemU("Square")". I'm not up to speed on that and can't test your code because of the missing reference.

Thanks.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,829
Messages
6,162,229
Members
451,756
Latest member
tommyw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top