none
ActiveX control inside PowerPoint slide RRS feed

  • Question

  • I've created a very simple program and exposed it as an ActiveX Control. What I'm trying to do is to embed this control into a PowerPoint slide. The code for the program is as follows:

    namespace WindowsFormsApplication1
    {
        [ProgId("Tomor.Form1")]
        [ClassInterface(ClassInterfaceType.AutoDispatch)]
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                button1.Text = "Clicked";
            }
        }
    }

    I've cheked the Make the assembly COM-visible and also checked the Register for COM-interop. I've also implemented the RegisterClass and UnregisterClass methods (but haven't shown here, see www dot telerik dot com/support/kb/winforms/general/wrapping-a-net-user-control-as-an-activex.aspx, for an exact implementation), and have been able to successfully register it using regasm.exe. I'm also able to access the interface from another project using Tomor1.Form. Now, I am trying to insert this control into a PowerPoint slide as follows:

          PowerPoint.Shape s = Sld.Shapes.AddOLEObject(0, 0, 400, 400, "Tomor.Form1");

    However, all I am getting is the following error upon startup:

    • $exception {"Could not read key from registry (Exception from HRESULT: 0x80040150 (REGDB_E_READREGDB))"} System.Exception {System.Runtime.InteropServices.COMException}

    The interesting thing is that I can see the "key" in registry by navigating to:Compuer\HKEY_CLASSES_ROOT\Tomor1.Form\CLSID

    Saturday, August 31, 2013 9:49 PM

Answers

  • Hi ttomor,
    According to your description, I think your issue is related to the COM registering.

    I found that your registry path is not consistent with Other ActiveX controls.

    For example:
    We can embed an ActiveX control “Common Button” into the PowerPoint slide with the code below and that works fine.

    Microsoft.Office.Interop.PowerPoint.Shape s = Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes.AddOLEObject(1, 1, 100, 100, "Forms.CommandButton.1");

    And the registry path of the “Common Button” is “Compuer\HKEY_CLASSES_ROOT\CLSID\ {0006F04A-0000-0000-C000-000000000046}\...  “

    So I suggest you editing the path of your control as the same as other ActiveX controls. Here is a reference may give you some help: Registering Assemblies with COM.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, September 5, 2013 2:43 AM
    Moderator