ActiveX in Word document

O

Ophelia

Hi!
Can anyone help me?
I try to insert my ActiveX control into Word document. What is the best way
to do it? I've found information about it on
http://msdn2.microsoft.com/es-es/li...p.word.inlineshapes.addolecontrol(VS.80).aspx and other, but...
When I try to add control to InlineShapes collection, I get exception
"Unknown error" and “Error! Not a valid embedded object.†in document text.

I can insert control in Shapes collection:

object objClass = "UContrl.UserControl"; //ProgId of my control

object shapes = Document.GetType().InvokeMember("Shapes",
BindingFlags.GetProperty, null, Document, null);

object mControl = shapes.GetType().InvokeMember("AddOLEControl",
BindingFlags.InvokeMethod, null, shapes, new object[] {objClass, left, top,
width, height, myRange});

and control works well, but Word's Com-object becomes inaccessible and even
the user can't close this document, like in Excel when some cell is edited...
P.S.: I use VS .NET 2003, C#.
 

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