Esempio n. 1
0
        void DisplayAddress_BeforeCaptionShow(object sender,
                                              Microsoft.Office.Tools.Excel.ActionEventArgs e)
        {
            Microsoft.Office.Tools.Excel.Action clickedAction =
                sender as Microsoft.Office.Tools.Excel.Action;

            if (clickedAction != null)
            {
                clickedAction.Caption = "Display the address of " +
                                        e.Text;
            }
        }
Esempio n. 2
0
        private void AddSmartTagToWorkbook(Excel.Workbook workbook)
        {
            Microsoft.Office.Tools.Excel.SmartTag smartTagDemo =
                // Create a smart tag for .NET Framework 3.5 projects.
                // new Microsoft.Office.Tools.Excel.SmartTag(
                //    "www.microsoft.com/Demo#DemoSmartTag",
                //    "Demonstration Smart Tag");
                // Create a smart tag for .NET Framework 4 projects.
                Globals.Factory.CreateSmartTag(
                    "www.microsoft.com/Demo#DemoSmartTag",
                    "Demonstration Smart Tag");

            // Specify a term and an expression to recognize.
            smartTagDemo.Terms.Add("sale");
            smartTagDemo.Expressions.Add(
                new System.Text.RegularExpressions.Regex(
                    @"[I|i]ssue\s\d{5,6}"));

            // Create the action for .NET Framework 3.5 projects.
            // displayAddress = new Microsoft.Office.Tools.Excel.Action(
            //    "To be replaced");
            // Create the action for .NET Framework 4 projects.
            displayAddress = Globals.Factory.CreateAction("To be replaced");

            // Add the action to the smart tag.
            smartTagDemo.Actions = new
                                   Microsoft.Office.Tools.Excel.Action[] { displayAddress };

            // Get the host item for the workbook in .NET Framework 3.5 projects.
            // Microsoft.Office.Tools.Excel.Workbook vstoWorkbook =
            //    workbook.GetVstoObject();
            // Get the host item for the workbook in .NET Framework 4 projects.
            Microsoft.Office.Tools.Excel.Workbook vstoWorkbook =
                Globals.Factory.GetVstoObject(workbook);

            // Add the smart tag to the active workbook.
            vstoWorkbook.VstoSmartTags.Add(smartTagDemo);

            displayAddress.BeforeCaptionShow += new
                                                Microsoft.Office.Tools.Excel.BeforeCaptionShowEventHandler(
                DisplayAddress_BeforeCaptionShow);

            displayAddress.Click += new
                                    Microsoft.Office.Tools.Excel.ActionClickEventHandler(
                DisplayAddress_Click);
        }