Programmatically expand Shapes

Started by ctrollen, September 22, 2010, 03:45:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ctrollen

We have a Visio-based add-on (written in C++) that uses a template .VST file as its start point.  Each of the many template files we use contains several Shape groups that are displayed within the Shapes pane.

I would like to be able to programmatically expand (or close) a particular group of shapes - by default they are not expanded and the user has to click the bar of the requisite group to expand it. 

I can access the relevant CSVDocument but there appears to be no call to expand the window; calling Open() on it simply opens a whole new child window, which is not what I want.

How would I go about this?

Thanks in advance.

Jumpy

#1
Here is how it's done in VBA. Maybe you can learn enough from it for C++.
I translated it partly to english as the names of variables and functions were in german.
So "Schablone", which can still be found as variablename is the german word for stencil.


Sub GetStencil()
 Sten "HereYourStencilNameWithout'.vss'"
End Sub

Public Sub Sten(Schablone As String)
'*******************************************
'* Gets Stencil to foreground              *
'*******************************************
Dim strSchablone As String
Dim stnObj As Document

strSchablone = Schablone
If IsStenOpen(strSchablone) = False Then
 strSchablone = strSchablone & ".VSS"
 Documents.OpenEx strSchablone, visOpenDocked
End If
Set stnObj = Documents(strSchablone)

End Sub

Public Function IsStenOpen(ByVal Schablonenname As String)
'Checks, if stencil is open

Dim stnObj As Document
Dim blnOffen As Boolean

blnOffen = False

For Each stnObj In Application.Documents
If Schablonenname = stnObj.Name Then
 blnOffen = True
 Exit For
End If
Next

IsStenOpen = blnOffen

End Function



Edit: Used this Code with Visio 2007. Just saw, that you need it for 2010. Don't know, if it will work there, too.

Paul Herber

Can you post a few screen shots of what this "expansion" involves?
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Nikolay

#3
Supposing that "expanding a shape group" === "maximizing a docked stencil",
the idea expressed by Jumpy can well be formulated as "you could try OpenEx(...,visOpenDocked + visOpenRO) instead of Open(...)"

Alternatively, you could use:
yourDrawingWindow.Windows.ItemEx("Your Stencil").Activate

ctrollen

Using Documents().OpenEX(vstrStencilName, visOpenDocked) worked great - thanks all!