Cannot Open the Stencil window using Controls

A

Alex Linares

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
 

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