Announcement

Collapse
No announcement yet.

Probleme Mit eigenem Add-In

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Probleme Mit eigenem Add-In

    Hallo Leute.
    Ich schreibe an einem Add-In für MS-Office Word 2003. das erstellen der Connect-Klasse und des dadrin programmierten Buttons hat eine Zeit lang funktioniert, doch plötzlich erscheint der Button nicht mehr beim Debuggen ín der Menüleiste. Selbst wenn ich ein kommplett neues Projekt erstelle und mich an die Codevorgaben von Microsoft halte, wird das Add-in nicht geladen.

    Kann mir einer erklären warum?

    der Coder der Connect-Klasse:
    Code:
    {
        using System;
        using Extensibility;
        using System.Runtime.InteropServices;
        using Microsoft.Office.Core;
        using System.Reflection;
    	#region Read me for Add-in installation and setup information.
    	// When run, the Add-in wizard prepared the registry for the Add-in.
    	// At a later time, if the Add-in becomes unavailable for reasons such as:
    	//   1) You moved this project to a computer other than which is was originally created on.
    	//   2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
    	//   3) Registry corruption.
    	// you will need to re-register the Add-in by building the WaveSetup project, 
    	// right click the project in the Solution Explorer, then choose install.
    	#endregion
    	
    	/// <summary>
    	///   The object for implementing an Add-in.
    	/// </summary>
    	/// <seealso class='IDTExtensibility2' />
    	[GuidAttribute("09853672-38AD-43A6-A2D0-A116692C648B"), ProgId("Wave.Connect")]
    	public class Connect : Object, Extensibility.IDTExtensibility2
    	{
            private object applicationObject;
            private object addInInstance;
            private CommandBarButton MyButton;
            private Vorlagenverwaltung vw;
    
    
    
            /// <summary>
            ///		Implements the constructor for the Add-in object.
            ///		Place your initialization code within this method.
            /// </summary>
            public Connect()
            {
                vw = new Vorlagenverwaltung(((Microsoft.Office.Interop.Word.Application)this.applicationObject));
            }
    
            public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
            {
                applicationObject = application;
                addInInstance = addInInst;
    
                if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
                {
                    OnStartupComplete(ref custom);
                }
    
            }
    
            public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
            {
                if (disconnectMode != Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
                {
                    OnBeginShutdown(ref custom);
                }
                applicationObject = null;
            }
    
    
            public void OnAddInsUpdate(ref System.Array custom)
            {
            }
    
            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"];
                }
    
                // In case the button was not deleted, use the exiting one.
                try
                {
                    MyButton = (CommandBarButton)oStandardBar.Controls["Vorlagenverwaltung"];
                }
                catch (Exception)
                {
                    object omissing = System.Reflection.Missing.Value;
                    MyButton = (CommandBarButton)oStandardBar.Controls.Add(1, omissing, omissing, omissing, omissing);
                    MyButton.Caption = "Vorlagenverwaltung";
                    MyButton.Style = MsoButtonStyle.msoButtonCaption;
                }
    
                // The following items are optional, but recommended. 
                //The Tag property lets you quickly find the control 
                //and helps MSO keep track of it when more than
                //one application window is visible. The property is required
                //by some Office applications and should be provided.
                MyButton.Tag = "Vorlagenverwaltung";
    
                // The OnAction property is optional but recommended. 
                //It should be set to the ProgID of the add-in, so that if
                //the add-in is not loaded when a user presses the button,
                //MSO loads the add-in automatically and then raises
                //the Click event for the add-in to handle. 
                MyButton.OnAction = "!<MyCOMAddin.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);
    
                // Display a simple message to show which application you started in.
                System.Windows.Forms.MessageBox.Show("This Addin is loaded by " + oName.ToString(), "MyCOMAddin");
                oStandardBar = null;
                oCommandBars = null;
    
            }
    
            public void OnBeginShutdown(ref System.Array custom)
            {
                vw.Close();
                object omissing = System.Reflection.Missing.Value;
                System.Windows.Forms.MessageBox.Show("MyCOMAddin Add-in is unloading.");
                MyButton.Delete(omissing);
                MyButton = null;
            }
    
            private void MyButton_Click(CommandBarButton cmdBarbutton, ref bool cancel)
            {
                vw.Show();
                vw.Enabled = true;
            }
    
            public Vorlagenverwaltung getVerwaltung()
            {
                return this.vw;
            }
        }
    }
Working...
X