Visio automation of viewer control?

0

0rbital

Hello,

I have been given the task to automate a Visio P&ID drawing. The
automation is very simple I need to allow the user to click on a valve and
then set an IO point on a machine and change the color of the valve shape to
green or red depending on the state of the IO. Now I can load the drawing
fine with the viewer or draw controls in .Net. I prefer to use the viewer as
the interface is nice and clean for zooming and the user will never change
the drawing. Can I automate with the viewer control or must I use the draw
control? All I need to get is a click event off the valve shapes to set my
IO. I have never worked with Visio drawings before and the whole thing is a
bit confusing.

Thanks
 
D

David Parker

The Visio Viewer control does indeed have an API (Microsoft Visio Viewer
12.0 Type Library) that reports back the selected shape (note that the
selection is limited to a single shape in the Viewer)
However, all you get back is the shape index, but you can use the index to
get the custom properties/shape data (and hyperlinks) of the selected
shape...

Private Sub AxViewer1_OnSelectionChanged(ByVal sender As Object, _
ByVal e As
AxVisioViewer._IViewerEvents_OnSelectionChangedEvent) Handles
AxViewer1.OnSelectionChanged
Try
'You can get Me.AxViewer1.CurrentPageIndex
'and e.shapeIndex
'Use Me.AxViewer1.get_CustomPropertyCount(lShape) to get the number of
SHape Data rows
'Loop thru using, or similar,
For lProperty As Integer = 1 To
Me.AxViewer1.get_CustomPropertyCount(lShape)
Dim propName as string .=
Me.AxViewer1.get_CustomPropertyName(lShape, lProperty))
Dim propVal as String =
Me.AxViewer1.get_CustomPropertyValue(e.shapeIndex, lProperty)

Next lProperty

Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.InnerException.Message)
End Try
End Sub

You can then use this information to access a database or something....
 

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