Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / April 2006

Tip: Looking for answers? Try searching our database.

AddOLEObject

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Johan - 25 Apr 2006 09:01 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.