Closing all stencils associated with a document?

J

Joshua Ochs

I'm trying to write a quick "cleanup" utility for when a Visio document
is receievd with a large number of open stencils. Is there any way to
find out all of the stencils that are associated with a document (they
open when the document is opened) and close them?

I tried using "DockedStencils" as a way to get at these and close them,
but now I'm getting some documents that have open stencils associated
with them, but they are open in their own non-docked windows. I've tried
iterating through the Documents property and closing all "*.vss" files,
but that inadvertently closes stencils that were open in other documents
(and you may want to keep open).

On another cleanup-related topic, when a document is opened in several
windows (such as to multiple different pages), is there any way to
easily close all of the "other views" besides the active one?

Thanks,

- Joshua Ochs

[I've received documents with dozens of stencil files left open (some
that are not present on my system, which hits me with multiple error
messages).]
 
A

Al Edlund

I use something like this (vb.net).
al
Private Sub setVisioExtraWindowVisibility( _

ByVal targetWindow As Microsoft.Office.Interop.Visio.Window, _

ByVal visVWT As Microsoft.Office.Interop.Visio.VisWinTypes, _

ByVal visible As Boolean)

Dim searchWindow As Microsoft.Office.Interop.Visio.Window

Try

' for identified window set the visibility attribute

searchWindow = targetWindow.Windows.ItemFromID(visVWT)

If (Not searchWindow Is Nothing) Then

searchWindow.Visible = visible

End If

Catch err As Exception

System.Diagnostics.Debug.WriteLine(err.Message)

End Try

End Sub



Public Sub ClearExtraWindows(ByVal targetWindow As
Microsoft.Office.Interop.Visio.Window)

Dim vsoWindow As Microsoft.Office.Interop.Visio.Window

Try

For Each vsoWindow In targetWindow.Windows

' if its an addon or shape-stencil turn off visibility

If vsoWindow.Type = 10 Or vsoWindow.Type = 7 Then

' vsoWindow.Visible = False

setVisioExtraWindowVisibility(targetWindow, vsoWindow.ID, False)

End If

Next

Catch err As Exception

MsgBox(err.Message)

End Try

End Sub
 

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