Can't add anchored window

Started by llmmnnoo2002, April 29, 2008, 01:33:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

llmmnnoo2002

Hello,

I am writing a C# Visio COM-AddIn for visio 2007 using Visual Studio 2005.

I am trying to add an anchored window using the Windows.Add method, but I can only choose VisWinTypes.visStencilAddon as a type. All other types always result in the exception "Invalid window type for this action".

When the type is VisWinTypes.visStencilAddon, a window does appear (no exception).

The code that throws the exception is

Window visioWindow = vsoApplication.Windows.Add(
VisWindowStates.visWSAnchorLeft |
VisWindowStates.visWSAnchorAutoHide |
VisWindowStates.visWSVisible,
VisWinTypes.visAnchorBarBuiltIn
,55, 55, 100, 100, null, null, null);

I have tried many variations with the argumets, but when VisWinTypes is not visStencilAddon, the exception occures.
It is possible that the problem is not with the VisWinType, but with the other argumets. I just don't know.

Any ideas ?

Thanks

Visio Guy

Hi "I"...

The anchor windows need to anchor to a document window, so I believe you are still one level too high. Try something like this:

Visio.Application.Windows(1).Windows.Add(...)
Visio.Application.ActiveWindow.Add(...)

Your code was trying to add a window to the application's window - ie: the main Visio window.

Does that make any sense?
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

llmmnnoo2002

#2
It works! the exception is no longer there and an anchored window does appear.
Many thanks for the quick reply.