Cannot access Visio Drawing Control objects

J

Jyothi

Hi

I have Created a Visio drawing control on to my C# windows form and when i
try to access drawing control objects like

VisApp = (Visio.Application)axDrawingControl1.Window.Application;

its giving InvalidActiveXStateException for axDrawingControl1.Window

any suggestions?

Here is my code


resources = new System.Resources.ResourceManager(typeof(Form2));
this.axDrawingControl1 = new
AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl()
((System.ComponentModel.ISupportInitialize)(this.axDrawingControl1)).BeginInit();
this.SuspendLayout();
//
// axDrawingControl1
//
// this.axDrawingControl1.AccessibleRole =
System.Windows.Forms.AccessibleRole.TitleBar;
this.axDrawingControl1.Enabled = true;
this.axDrawingControl1.Location = new System.Drawing.Point(88, 16);
this.axDrawingControl1.Name = "axDrawingControl1";
this.axDrawingControl1.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("axDrawingControl1.OcxState")));
this.axDrawingControl1.Size = new System.Drawing.Size(648, 528);
this.axDrawingControl1.TabIndex = 19;


this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form2"
((System.ComponentModel.ISupportInitialize)(this.axDrawingControl1)).EndInit();


VisApp = (Visio.Application)axDrawingControl1.Window.Application;
VisPage = (Visio.Page) axDrawingControl1.Document.Pages[1];
VisWindow = (Visio.Window) axDrawingControl1.Window;
VisDocument = (Visio.Document) axDrawingControl1.Document;
VisDocuments = (Visio.Documents)
axDrawingControl1.Window.Application.Documents;


VisStencil = VisApp.Documents.Add("Basic shapes.vss");
VisMaster = VisStencil.Masters.Add();
VisMaster.Name = "Rectangle";
VisMaster = VisStencil.Masters[("Rectangle")];
VisShape = VisApp.ActivePage.Drop(VisMaster, 4, 4);
VisShape.Text = "HELLO WORLD";


thanks
Jyothi
 
J

JuneTheSecond

I don't know how to write CV#, but
Visio.Application visapp = axDrawingControl1.Window.Application;
MessageBox.Show(visapp.Name);
is working in my ytest sample in "toolStripButton1_Click"
On top of this class there is a line like
using Visio = Microsoft.Office.Interop.Visio;
 
J

Jyothi

But in this statement axDrawingControl1.Window.Application
Application property of the Window cannot be accessible

is this something to do with Windows Registry? I havent registed Interop
Dlls with Registry. Just i downloaded PIA's from Microsoft site and ran the
msi.

Thanks
Jyothi

JuneTheSecond said:
I don't know how to write CV#, but
Visio.Application visapp = axDrawingControl1.Window.Application;
MessageBox.Show(visapp.Name);
is working in my ytest sample in "toolStripButton1_Click"
On top of this class there is a line like
using Visio = Microsoft.Office.Interop.Visio;

--
JuneTheSecond



Jyothi said:
Hi

I have Created a Visio drawing control on to my C# windows form and when i
try to access drawing control objects like

VisApp = (Visio.Application)axDrawingControl1.Window.Application;

its giving InvalidActiveXStateException for axDrawingControl1.Window

any suggestions?

Here is my code


resources = new System.Resources.ResourceManager(typeof(Form2));
this.axDrawingControl1 = new
AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl();
((System.ComponentModel.ISupportInitialize)(this.axDrawingControl1)).BeginInit();
this.SuspendLayout();
//
// axDrawingControl1
//
// this.axDrawingControl1.AccessibleRole =
System.Windows.Forms.AccessibleRole.TitleBar;
this.axDrawingControl1.Enabled = true;
this.axDrawingControl1.Location = new System.Drawing.Point(88, 16);
this.axDrawingControl1.Name = "axDrawingControl1";
this.axDrawingControl1.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("axDrawingControl1.OcxState")));
this.axDrawingControl1.Size = new System.Drawing.Size(648, 528);
this.axDrawingControl1.TabIndex = 19;


this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form2";
((System.ComponentModel.ISupportInitialize)(this.axDrawingControl1)).EndInit();


VisApp = (Visio.Application)axDrawingControl1.Window.Application;
VisPage = (Visio.Page) axDrawingControl1.Document.Pages[1];
VisWindow = (Visio.Window) axDrawingControl1.Window;
VisDocument = (Visio.Document) axDrawingControl1.Document;
VisDocuments = (Visio.Documents)
axDrawingControl1.Window.Application.Documents;


VisStencil = VisApp.Documents.Add("Basic shapes.vss");
VisMaster = VisStencil.Masters.Add();
VisMaster.Name = "Rectangle";
VisMaster = VisStencil.Masters[("Rectangle")];
VisShape = VisApp.ActivePage.Drop(VisMaster, 4, 4);
VisShape.Text = "HELLO WORLD";


thanks
Jyothi
 
J

JuneTheSecond

My test code is simply as above.
Nothing to do about register.
My test is in Visio2007 and .Net2005.
 
M

Michel LAPLANE

Verify that the microsoft.office.interop.visocx assembly is in the
Windows\assmbly directory.

You code seems good.
Is that code be generated par VS when you have insert the VDC in you
application form ?

Jyothi said:
But in this statement axDrawingControl1.Window.Application
Application property of the Window cannot be accessible

is this something to do with Windows Registry? I havent registed Interop
Dlls with Registry. Just i downloaded PIA's from Microsoft site and ran
the
msi.

Thanks
Jyothi

JuneTheSecond said:
I don't know how to write CV#, but
Visio.Application visapp = axDrawingControl1.Window.Application;
MessageBox.Show(visapp.Name);
is working in my ytest sample in "toolStripButton1_Click"
On top of this class there is a line like
using Visio = Microsoft.Office.Interop.Visio;

--
JuneTheSecond



Jyothi said:
Hi

I have Created a Visio drawing control on to my C# windows form and
when i
try to access drawing control objects like

VisApp =
(Visio.Application)axDrawingControl1.Window.Application;

its giving InvalidActiveXStateException for axDrawingControl1.Window

any suggestions?

Here is my code


resources = new System.Resources.ResourceManager(typeof(Form2));
this.axDrawingControl1 = new
AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl();
((System.ComponentModel.ISupportInitialize)(this.axDrawingControl1)).BeginInit();
this.SuspendLayout();
//
// axDrawingControl1
//
// this.axDrawingControl1.AccessibleRole =
System.Windows.Forms.AccessibleRole.TitleBar;
this.axDrawingControl1.Enabled = true;
this.axDrawingControl1.Location = new System.Drawing.Point(88, 16);
this.axDrawingControl1.Name = "axDrawingControl1";
this.axDrawingControl1.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("axDrawingControl1.OcxState")));
this.axDrawingControl1.Size = new System.Drawing.Size(648, 528);
this.axDrawingControl1.TabIndex = 19;


this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form2";
((System.ComponentModel.ISupportInitialize)(this.axDrawingControl1)).EndInit();


VisApp =
(Visio.Application)axDrawingControl1.Window.Application;
VisPage = (Visio.Page) axDrawingControl1.Document.Pages[1];
VisWindow = (Visio.Window) axDrawingControl1.Window;
VisDocument = (Visio.Document) axDrawingControl1.Document;
VisDocuments = (Visio.Documents)
axDrawingControl1.Window.Application.Documents;


VisStencil = VisApp.Documents.Add("Basic shapes.vss");
VisMaster = VisStencil.Masters.Add();
VisMaster.Name = "Rectangle";
VisMaster = VisStencil.Masters[("Rectangle")];
VisShape = VisApp.ActivePage.Drop(VisMaster, 4, 4);
VisShape.Text = "HELLO WORLD";


thanks
Jyothi
 

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