Beispiel #1
0
        /// <summary>
        /// Imports standard module to the active VB project.
        /// If already exists, VBE will generate unique name automatically
        /// </summary>
        /// <param name="vbe">a reference to the VBE</param>
        /// <param name="item">a form to be imported</param>
        /// <param name="shouldOverride">true if the component should be overridden</param>
        public virtual void Import(Microsoft.Vbe.Interop.VBE vbe, Component item, bool shouldOverride)
        {
            VBProject vbProject = vbe.ActiveVBProject;

            vbProject.VBComponents.Import(item.FullPath);
        }
Beispiel #2
0
        public void OnConnection(object application, ext_ConnectMode ConnectMode, object AddInInst, ref System.Array custom)
        {
            vbe = ((VBIDE.VBE) application);

            // VBEのメニューにコマンドを登録
            Office.CommandBar cmdBar = vbe.CommandBars[1];

            cmdBarPopup = (Office.CommandBarPopup)cmdBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            cmdBarPopup.Caption = "&Comment";

            // コメントアウト コマンド
            Office.CommandBarButton cmdCommentOut;
            cmdCommentOut = (Office.CommandBarButton)cmdBarPopup.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
            cmdCommentOut.Caption = "&Comment Out";
            cmdCommentOut.ShortcutText = "'";
            cmdCommentOut.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdCommentOut_Click);
            cmdCommentOut.Visible = true;

            // Globalコメント コマンド
            Office.CommandBarButton cmdGlobalComment;
            cmdGlobalComment = (Office.CommandBarButton)cmdBarPopup.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
            cmdGlobalComment.Caption = "&Global Comment";
            cmdGlobalComment.ShortcutText = "'***";
            cmdGlobalComment.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdGlobalComment_Click);
            cmdGlobalComment.Visible = true;

            // Privateコメント コマンド
            Office.CommandBarButton cmdPrivateComment;
            cmdPrivateComment = (Office.CommandBarButton)cmdBarPopup.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
            cmdPrivateComment.Caption = "&Private Comment";
            cmdPrivateComment.ShortcutText = "'---";
            cmdPrivateComment.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdPrivateComment_Click);
            cmdPrivateComment.Visible = true;

            // 日付コメント コマンド
            Office.CommandBarButton cmdDateComment;
            cmdDateComment = (Office.CommandBarButton)cmdBarPopup.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
            cmdDateComment.Caption = "&Date Comment";
            cmdDateComment.ShortcutText = "' yyyy/mm/dd";
            cmdDateComment.Click += new Office._CommandBarButtonEvents_ClickEventHandler(cmdDateComment_Click);
            cmdDateComment.Visible = true;
        }