Microsoft KB Archive/885121

= A docked stencil opens in the instance of the Visio ActiveX control that was last active when you use the OpenEx method in Visio =

Article ID: 885121

Article Last Modified on 6/13/2007

-

APPLIES TO


 * Microsoft Office Visio Professional 2007
 * Microsoft Office Visio Standard 2007
 * Microsoft Office Visio Professional 2003
 * Microsoft Office Visio Standard 2003

-



SYMPTOMS
You create a custom program that uses multiple instances of the Microsoft Visio ActiveX control, also known as the Visio drawing control. If you use the OpenEx method to open a docked stencil in the custom program, the stencil opens in the last Visio drawing control that was active. Additionally, there is no way to make a different instance of the drawing control open the stencil.

The following is an example of Microsoft Visual C# .NET code that demonstrates the symptoms that you experience: axDrawingControl1.Document.Application.Documents.OpenEx(&quot;Basic_U.vss&quot;,(short)Visio.VisOpenSaveArgs.visOpenDocked); axDrawingControl2.Document.Application.Documents.OpenEx(&quot;Basic_U.vss&quot;,(short)Visio.VisOpenSaveArgs.visOpenDocked);



CAUSE
This issue occurs because multiple instances of the Visio drawing control use the same instance of the application object. In the code example that is in the &quot;Symptoms&quot; section, the application object that is returned by the axDrawingControl1.Document.Application code is the same object as the application object that is returned by the axDrawingControl2.Document.Application code.

When you use the OpenEx method to open a stencil, the code does not contain a reference to tell Visio which instance of the drawing control to use to open the stencil. Therefore, Visio cannot determine the instance of the drawing control where you want to open the stencil. You have to set the focus on the instance of the Visio drawing control where you want to open the docked stencil before the stencil opens in that particular instance.



WORKAROUND
To work around this issue, set the focus on the instance of the Visio drawing control where you want to open the docked stencil before you use the OpenEx method to open the stencil. The following is an example of code that demonstrates this workaround.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Note The sample code in this article uses Visual C# .NET. axDrawingControl1.Focus; axDrawingControl1.Document.Application.Documents.OpenEx(&quot;Basic_U.vss&quot;,(short)Visio.VisOpenSaveArgs.visOpenDocked);

axDrawingControl2.Focus; axDrawingControl2.Document.Application.Documents.OpenEx(&quot;Basic_U.vss&quot;,(short)Visio.VisOpenSaveArgs.visOpenDocked);



MORE INFORMATION
When you use the Visio drawing control, you can treat each instance of the drawing control as a separate program window. You can programmatically tell Visio which program window you want to use as the active program window. For example, you can use the SetFocus method to move the focus to the instance of the Visio drawing control that you want.

For more information about the Visio drawing control, visit the following Microsoft Web sites.

Microsoft Office Visio 2007
http://msdn2.microsoft.com/en-us/library/aa342061.aspx

http://msdn2.microsoft.com/en-us/library/aa342062.aspx

Microsoft Office Visio 2003
http://msdn2.microsoft.com/en-us/library/aa173510(office.11).aspx

http://msdn2.microsoft.com/en-us/library/aa168480(office.11).aspx

Additional query words: drawingcontrol visio2003 visio2k3 visio11 vso2003 vso2k3 vso11 visio2007 visio2k7 visio12 vso2007 vso2k7 vso12

Keywords: kbexpertiseinter kbopenfile kbprb kbtshoot KB885121

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.