tags:

views:

12

answers:

0

i am using this code to add an item to microsoft powerpoint

public void OnStartupComplete(ref System.Array custom) { CommandBars oCommandBars; CommandBar oStandardBar;

        try
        {
            oCommandBars = (CommandBars)applicationObject.GetType().InvokeMember("CommandBars",

BindingFlags.GetProperty, null, applicationObject, null); } catch (Exception) { // Outlook has the CommandBars collection on the Explorer object. object oActiveExplorer; oActiveExplorer = applicationObject.GetType().InvokeMember("ActiveExplorer", BindingFlags.GetProperty, null, applicationObject, null); oCommandBars = (CommandBars)oActiveExplorer.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, oActiveExplorer, null); }

        // Set up a custom button on the "Standard" commandbar.
        try
        {
            oStandardBar = oCommandBars["Standard"];
        }
        catch (Exception)
        {
            // Access names its main toolbar Database.
            oStandardBar = oCommandBars["Database"];
        }


        try
        {
            MyButton = (CommandBarButton)oStandardBar.Controls["My

Custom Button"]; } catch (Exception) { object omissing = System.Reflection.Missing.Value; MyButton = (CommandBarButton)oStandardBar.Controls.Add(1, omissing, omissing, omissing, omissing); MyButton.Caption = "My Custom Button"; MyButton.Style = MsoButtonStyle.msoButtonCaption; }

        MyButton.Tag = "My Custom Button";


        MyButton.OnAction = "!<MyAddin2.Connect>";

        MyButton.Visible = true;
        MyButton.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.MyButton_Click);


        object oName = applicationObject.GetType().InvokeMember("Name",

BindingFlags.GetProperty, null, applicationObject, null);

        >             System.Windows.Forms.MessageBox.Show("This

Addin is loaded by " + oName.ToString(), "MyAddin2"); oStandardBar = null; oCommandBars = null; }

now when , i am trying ot compile this code , it is compiling well , but not creating button on the standard bar of powerpoint...

what should i do to correct it??