Hi,
I'm working on a project, where the user clicks on a button, which I've
added to all Office applications, and an activex controller gets inserted to
the current document. This is the code for inserting the controller, in c#
and for powerpoint.
Microsoft.Office.Interop.PowerPoint.Shape shape =
application.ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(120, 120,
320, 240, "TESTX.TestXCtrl.1", "", MsoTriState.msoFalse, null, 0, "Test",
MsoTriState.msoFalse);
Although this works like a charm, I need to get a handle to the actuall
activex controller, so I can set properties. In VB this is easy, I just do
this:
Set ax =
ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(Left:=120, Top:=110,
Width:=480, Height:=320, ClassName:="TESTX.TestXCtrl.1", Link:=msoFalse)
Set obj = ax.OLEFormat.Object
obj.TestProperty = "Happy!"
And I know that I can get a handle to the object in c# the same way,
shape.OLEFormat.Object, but I dont know how to access the TestProperty
property of the controller, as I did with VB.
Any help is appreciated.
Regards
Helmut Obertanner - 26 Apr 2006 18:27 GMT
Hello Johann,
you can try to set the Property by latebinding...
// pass the parameters as objectarray
object[] params = new object[]{"Happy!"};
obj.GetType().InvokeMember("TestProperty",
System.Reflection.BindingFlags.SetProperty, null, obj, params);
regards

Signature
Helmut Obertanner
Senior Developer
MVP - Visual Developer VSTO
http://www.x4u.de
> Hi,
>
[quoted text clipped - 26 lines]
>
> Regards
Johan - 27 Apr 2006 12:05 GMT
Hi Helmut,
thank you for your help, it worked like a charm (I thought I tried it
already though, guess I did something wrong).
Regards
Johan
> Hello Johann,
>
[quoted text clipped - 38 lines]
> >
> > Regards