locked
VSTO, ActiveX, and Powerpoint RRS feed

  • Question

  • Is it possible to create an ActiveX control to embed into powerpoint for interactivity and create it using VSTO/C#?
    Thursday, August 23, 2007 4:38 PM

Answers

  • Hi,

     

    You can create an Active X control using C#.  To do this, you would need to create Runtime Callable Wrappers for every COM interface and type that you will need to implement an ActiveX control.  Since Powerpoint will require a full OLE control, this will be non-trivial. 

     

    A less labor intensive approach would be to use the C++ MFC control project.  This will do much of the heavy lifting for you and will greatly simplify your development effort.  Once you have your control created, you could just use TLBIMP.EXE to generate an interop assembly containing the RCW's for you to interop with.  I would recommend this approach.

     

    If you do create a full managed ActiveX control implementation, you would probably not want to do this from within a VSTO customization (though you certainly could) unless there is some reason why your control should be so coupled. 

     

    ActiveX controls are a serious undertaking that require a great deal of code.  You can certainly ask for a "sample", but I doubt you are going to get one (particularly a managed one).  If you really want to write an ActiveX control without using MFC, your best bet would be to try to obtain a copy of Kraig Brockschmidt's "Inside OLE2".  This will have sample code for most of the interfaces you'll need (albeit in native code). 

     

    Sincerely,

     

    Geoff Darst

    Microsoft VSTO Team

    Monday, August 27, 2007 5:23 PM
    Answerer

All replies

  • If so, does anyone have any source code of example controls?
    Thursday, August 23, 2007 4:39 PM
  • Hi,

     

    You can create an Active X control using C#.  To do this, you would need to create Runtime Callable Wrappers for every COM interface and type that you will need to implement an ActiveX control.  Since Powerpoint will require a full OLE control, this will be non-trivial. 

     

    A less labor intensive approach would be to use the C++ MFC control project.  This will do much of the heavy lifting for you and will greatly simplify your development effort.  Once you have your control created, you could just use TLBIMP.EXE to generate an interop assembly containing the RCW's for you to interop with.  I would recommend this approach.

     

    If you do create a full managed ActiveX control implementation, you would probably not want to do this from within a VSTO customization (though you certainly could) unless there is some reason why your control should be so coupled. 

     

    ActiveX controls are a serious undertaking that require a great deal of code.  You can certainly ask for a "sample", but I doubt you are going to get one (particularly a managed one).  If you really want to write an ActiveX control without using MFC, your best bet would be to try to obtain a copy of Kraig Brockschmidt's "Inside OLE2".  This will have sample code for most of the interfaces you'll need (albeit in native code). 

     

    Sincerely,

     

    Geoff Darst

    Microsoft VSTO Team

    Monday, August 27, 2007 5:23 PM
    Answerer
  • Hi Geoff,

    It sounds like I've made a mistake with my managed ActiveX implementation which doesn't implement much in terms of the interfaces required.  I've got my control to work in Visual Foxpro but not in MS Word.  I just want to implement the bare minimum as this control is pure properties and a redrawing itself.  It does nothing in terms of interactivity, no events etc.  I was hoping this would keep it simple <g> 

    When you say create an MFC control do you mean wrapper or in majority of the control?  I've not investigated TLBIMP.exe, looks like I've got some reading to do.  In short your saying it is possible in managed code although a very long process of manually implementing the interfaces?  Is this more of a long winded task than a complex task? or is it both?

    Thanks

    NozFX
    Friday, January 22, 2010 8:11 PM
  • Hi!

    You can see an Example C# or VB.NET here
    http://cfx.codeplex.com/
    • Proposed as answer by NozFx Monday, February 1, 2010 1:13 PM
    Friday, January 22, 2010 9:51 PM
  • Hi Joao,

    Thanks for your reply.  Didn't realise this existed, what a cool idea.  How many examples we talking here, must be several.  Any idea what the sample name is that I would be interested in?

    Thanks

    NozFX 
    Monday, February 1, 2010 10:39 AM
  • Hi!

    Try CSActiveX for C# and VBActiveX for VB.NET

    You have only 1 example for each language

    If you use VB you can try this Forum

    VB and Interop
    http://social.msdn.microsoft.com/Forums/en-US/vbinterop/threads

    You can try also the VB Microsoft Interop Forms Toolkit 2.0, that generate you ActiveX Interface code automatically.
    http://msdn.microsoft.com/en-us/vbasic/bb419144.aspx
    • Proposed as answer by NozFx Monday, February 1, 2010 1:12 PM
    Monday, February 1, 2010 12:50 PM
  • Thanks for your prompt reply.  This sounds great!!

    Regards

    Richard
    Monday, February 1, 2010 1:12 PM