How to Show/Hide Custom Properties Window via VBA Code

L

lostwings

I got stuck for this problem for days. There are a lot of articles online
about how to add/set/get custom properties cells for a certain shape,
however, I cannot find one that is aiming at show/hide custom properties
window in a programmatical way, which I think should be much easier.

Appriciate any help and suggestion!
 
A

Al Edlund

here's a vb.net version that you should be able to modify, I've included the
visio window types as well

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

It uses some constants for window types that I renamed

Public Const visVWTAnchorBarAddon As Integer = 10

' Window created by an add-on that has tabs at the bottom when merged
(floating, anchored, or docked window)

Public Const visVWTAnchorBarBuiltIn As Integer = 6

' Visio built-in window that has tabs at the bottom when merged- presently,
the Custom Properties, Size & Position, Drawing Explorer, Master Explorer,
and Pan & Zoom windows (floating, anchored, or docked windows).

Public Const visVWTApplication As Integer = 5

' Microsoft Office Visio application window.

Public Const visVWTDockedStencilAddon As Integer = 11

'An add-on window that has docked stencil behavior.

Public Const visVWTDockedStencilBuiltIn As Integer = 7

' Stencil window docked in a drawing window.

Public Const visVWTDrawing As Integer = 1

' Drawing window (MDI frame window).

Public Const visVWTDrawingAddon As Integer = 8

'Drawing window created by an add-on (MDI frame window).

Public Const visVWTIcon As Integer = 4

'Icon editing window (MDI frame window).

Public Const visVWTInvalWinID As Integer = -1

'Window has no ID.

Public Const visVWTMasterGroupWin As Integer = 96

'A group editing window of a group in a master.

Public Const visVWTMasterWin As Integer = 64

'A master drawing page window.

Public Const visVWTPageGroupWin As Integer = 160

'A group editing window of a group on a page.

Public Const visVWTPageWin As Integer = 128

'A drawing window showing a page.

Public Const visVWTSheet As Integer = 3

'ShapeSheet window (MDI frame window).

Public Const visVWTStencil As Integer = 2

'Stencil window (MDI frame window).

Public Const visVWTStencilAddon As Integer = 9

'Add-on window that has stencil window behavior.

Public Const visVWTWinIDCustProp As Integer = 1658

'When Window.Type is visAnchorBarBuiltIn, Custom Properties window.

Public Const visVWTWinIDDrawingExplorer As Integer = 1721

'When Window.Type is visAnchorBarBuiltIn, Drawing Explorer window.

Public Const visVWTWinIDFormulaTracing As Integer = 1781

'When Window.Type is visAnchorBarBuiltIn, ShapeSheet Formula Tracing window.

Public Const visVWTWinIDMasterExplorer As Integer = 1916

'When Window.Type is visAnchorBarBuiltIn, Master Explorer window in master
editing window.

Public Const visVWTWinIDPanZoom As Integer = 1653

'When Window.Type is visAnchorBarBuiltIn, Pan & Zoom window.

Public Const visVWTWinIDShapeSearch As Integer = 1669

'When Window.Type is visAnchorBarBuiltIn, Shapes window.

Public Const visVWTWinIDSizePos As Integer = 1670

'When Window.Type is visAnchorBarBuiltIn, Size & Position window.

Public Const visVWTWinIDStencilExplorer As Integer = 1796

'When Window.Type is visAnchorBarBuiltIn, Drawing Explorer window in MDI
stencil window.

Public Const visVWTWinOther As Integer = 0

'Unknown window type.
 
L

lostwings

Thanks so much for your in time reply.

However, I still cannot fix the proble. According your code, I use the
following snippet to do things

Try
searchWindow =
vsoApplication.Windows.ItemFromID(Microsoft.Office.Interop.Visio.VisWinTypes.visWinIDCustProp)
if (Not searchWindow Is Nothing) Then
searchWindow.visible = visible
Catch err As Exception
System.Diagnostics.Debug.WriteLine(err.Message)
End Try

the vsoApplication is an visio.application type and searchWindow is a
visio.window type, and i got the err message from the catch err.

searchWindow =
vsoApplication.Windows.ItemFromID(Microsoft.Office.Interop.Visio.VisWinTypes.visWinIDCustProp)
is not working correctly. I have tried to use your constant integer as the
ItemFromID parameter, it also failed. I think that's because we cannot use
the Microsoft.Office.Interop.Visio.VisWinTypes as the input type for the
Windows.ItemFromID() function, is that true?
 
A

Al Edlund

I apologize for not having put it into context. The root of course is the
subroutine that sets the 'extra window visibility'. I use it to make windows
visible/hidden. The calling routine uses a format where it passes the
current application window (vsoApp.activewindow), the kind of window you
want to act upon, and whether you want to make it visible or hide it. The
object being acted upon is the viso window types (you'll find custom
properties down around 1658).
al
 
L

lostwings

The Code is working perfectly now. Actually, your previous post gave all the
detailed information on how to solve my problem. I messed up thing a little
bit so that the windows.ItemFromID function cannot locate the custon
property window objct right away, now everything looks so good. :)

Once again, thank u very much for all the help.
 

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