I am currently just testing out how to embed Visio within a Windows form.
I have the main FORM class that has these definitions:

public AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl axDrawingControl1;
....
public Form1()
{
InitializeComponent();
Visio.Application visioApp = null;
visioApp = (Visio.Application) this.axDrawingControl1.Window.Application;
this.axDrawingControl1.Src = "C:\\Program Files\\Microsoft
Office\\Visio11\\1033\\blank.vsd";
Diagram diag = new Diagram(visioApp);
...
}

This code calls another class, called Diagram in which I programmatically
create a diagram. Unfortunately, I get a run-time exception on the last line:
...
docsObj = visioApp.Documents;
docObj = docsObj.Add("Basic Diagram.vst");
pagsObj = visioApp.ActiveDocument.Pages;
pagObj = pagsObj[1];
***stnObj = visioApp.Documents["Basic Shapes.vss"];***
...

For some reason, the stencil window does not load within the control or the
form and this is what is causing the exception.

This code works perfectly fine if I just run it w/in Visio, replacing the
line :

visioApp = (Visio.Application) this.axDrawingControl1.Window.Application;
with
visioApp = new Visio.Application();

Any ideas? Am I forgetting to set something within the control?

Thanks in advance,
Alex

Re: Cannot Open the Stencil window using Controls by Kline

Kline
Wed Jun 08 02:19:01 CDT 2005

At least you managed to post this to microsoft.public.visio.developer,
unless *that* was a mistake :-)

On Tue, 7 Jun 2005 15:37:01 -0700, Alex Linares <Alex
Linares@discussions.microsoft.com> wrote:

>I am currently just testing out how to embed Visio within a Windows form.
>I have the main FORM class that has these definitions:
>
>public AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl axDrawingControl1;
>....
>public Form1()
>{
> InitializeComponent();
> Visio.Application visioApp = null;
> visioApp = (Visio.Application) this.axDrawingControl1.Window.Application;
> this.axDrawingControl1.Src = "C:\\Program Files\\Microsoft
>Office\\Visio11\\1033\\blank.vsd";
> Diagram diag = new Diagram(visioApp);
> ...
>}
>
>This code calls another class, called Diagram in which I programmatically
>create a diagram. Unfortunately, I get a run-time exception on the last line:
>...
>docsObj = visioApp.Documents;
>docObj = docsObj.Add("Basic Diagram.vst");
>pagsObj = visioApp.ActiveDocument.Pages;
>pagObj = pagsObj[1];
>***stnObj = visioApp.Documents["Basic Shapes.vss"];***
>...
>
>For some reason, the stencil window does not load within the control or the
>form and this is what is causing the exception.
>
>This code works perfectly fine if I just run it w/in Visio, replacing the
>line :
>
>visioApp = (Visio.Application) this.axDrawingControl1.Window.Application;
>with
>visioApp = new Visio.Application();
>
>Any ideas? Am I forgetting to set something within the control?
>
>Thanks in advance,
>Alex


Kline Sphere (Chalk) MCNGP #3