Programmatically simulate Visio selection through the Selection Object Collection

D

Denis Zavadil

Is there a means to display the contents of a programmatically generated
selection collection with the green dashed shape highlighting and control
handle display as are natively displayed in Visio when the user clicks on a
shape?
 
M

Mark Nelson [MS]

You can work with the ActiveWindow.Selection object. Use the DeselectAll
method to clear the current selection in the window. Use the Select method
to add or remove shapes from the current selection.
 
D

Denis Zavadil

Mark,

Thanks for the reply. I've previously unsuccessfully tried your suggestion
with the following code which add 17 shapes to the collection, then prints
the names of all 17 shapes. The problem is that there are no items visibly
selected on the display as if I were to manually select the shapes and they
have control handles highlit in green, which is what I'm attempting. By the
way, I'm using the Active X control within a vb.net application.

Dim objShape As Microsoft.Office.Interop.Visio.Shape

Dim objSelection As Microsoft.Office.Interop.Visio.Selection

objSelection = Me.axSchematic.Document.Application.ActiveWindow.Selection

objSelection.DeselectAll()

For Each objShape In Me.axSchematic.Window.Page.Shapes

objSelection.Select(objShape, visSelect)

Next

For Each objShape In objSelection

Console.WriteLine(objShape.Name)

Next

Windows.Forms.Application.DoEvents()
 

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