How to close stencils in one drawing control but not the other.

S

Stumple

I am working with multiple drawing controls and when I try and close the
stencils on it all the stencils on all of the drawing controls close.

foreach(Document document in
this.drawingControl.Document.Application.Documents) {
if (document.Type == VisDocumentTypes.visTypeStencil) {

document.Close();
}
}
 
D

David J Parker

That is because you need to close the Window that has the stencil document
in it.
For example, this macro will close the window in the active document that
has the "Borders and Titles" stencil in it
(Substitue "BORDER_M.VSS" with "BORDER_U.VSS" if you are using US units)

Public Sub CloseOne()
Dim ary() As String
Visio.ActiveWindow.DockedStencils ary
Dim i As Integer
For i = 0 To UBound(ary)
Debug.Print ary(i)
Next i
Dim doc As Visio.Document
Set doc = Visio.Documents("BORDER_M.VSS")
If not doc is Nothing Then
Debug.Print doc.Name
Dim win As Visio.Window
For Each win In Visio.ActiveWindow.Windows
If win.Document = doc Then
Debug.Print win.Caption
win.Close
End If
Next
End If
End Sub
 
S

Stumple

I'll try that. Do you see any reason that the following wouldn't work to
close all stencil windows?

foreach (Window w in
this.drawingControl.Document.Application.ActiveWindow.Windows)
if (w.Document.Type == VisDocumentTypes.visTypeStencil)
w.Close();
 

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