Doubleclick shape to display link row in external data

C

CMorrison

I would like to create a macro that will display the linked row in the
external data window when i double click a shape. I am using Visio 2007
professional.

Thanks

CMorrison
 
A

AlEdlund

When you say "display the linked row in the external data window ", do you
mean display the data as in a form or merely highlight the row in the
external data window?
Al
 
C

CMorrison

Highlight the row in the external data window. I am trying to do the same
thing as selecting Show Link row from the data menu.

Thanks
Cmorrison
 
A

AlEdlund

you might try something like this
al


Private Sub ShowSelectedObjectDataRecord(visShape As Visio.Shape)
'
' this piece of code handles selecting an object and then if it
' is linked to a data recordset, open the external data window and
' select the recordset and record appropriate to the object
'
Dim alngDataRecordsetIDs() As Long
Dim lngRowId As Long
Dim lngRecordSetId As Long
Dim winExternalData As Visio.Window
Dim visDataRecordset As Visio.DataRecordset
Dim intX As Integer

' get the list of recordset ids associated if any
visShape.GetLinkedDataRecordsetIDs alngDataRecordsetIDs

If UBound(alngDataRecordsetIDs) <> -1 Then
' take the first recordset id
lngRecordSetId = alngDataRecordsetIDs(0)
' get the associate row id
lngRowId = visShape.GetLinkedDataRow(lngRecordSetId)
Set winExternalData =
Application.ActiveWindow.Windows.ItemFromID(visWinIDExternalData)
' show the external data window
winExternalData.Visible = True
' set the linked row
Set visDataRecordset =
Application.ActiveDocument.DataRecordsets.ItemFromID(lngRecordSetId)
winExternalData.SelectedDataRecordset = visDataRecordset
winExternalData.SelectedDataRowID = lngRowId
End If ' test for number of recorsetids associated


End Sub
 
C

CMorrison

Thank you. Can i just copy this into a macro and run it, when I double click
the shape?
 
A

AlEdlund

One of the great tools in Visio is the macro recorder. You can use it to see
what happens when a shape is selected. The code I posted needs to know what
shape is selected before it can be run.
Short answer is that your 'double-click' code will have to identify the
shape from where the event is originating and then call the code I posted.
al
 

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