当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Office.Interop.Word.Activate方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Word.Activate方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Word.Activate方法的具体用法?C# Microsoft.Office.Interop.Word.Activate怎么用?C# Microsoft.Office.Interop.Word.Activate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Word的用法示例。


在下文中一共展示了Microsoft.Office.Interop.Word.Activate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: KeepNewWindowActivated

 void KeepNewWindowActivated(Word.Document Doc, Word.Window Wn)
 {
     if (newDoc == Doc)
     {
         Doc.Activate();
     }
 }
开发者ID:polx,项目名称:sandbox,代码行数:7,代码来源:AddinActionsDispatcher.cs

示例2: InsertFileIntoDocument

        private static void InsertFileIntoDocument(string insertedFile, Word.Application word, Word.Document document, bool BreakPageRequired = true)
        {
            document.Activate();

            // переключаем фокус на тело документа
            if (document.ActiveWindow.ActivePane.View.SeekView != Word.WdSeekView.wdSeekMainDocument)
                document.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument;

            object missing = Type.Missing;
            object story = Word.WdUnits.wdStory;

            word.Selection.EndKey(ref story, ref missing);

            if (BreakPageRequired == true)
            {
                object pageBreak = Word.WdBreakType.wdPageBreak;
                word.Selection.InsertBreak(ref pageBreak);
            }

            object link = false;
            object attachment = false;
            object confirm = false;

            word.Selection.InsertFile(insertedFile, ref missing, ref confirm, ref link, ref attachment);
        }
开发者ID:Rukhlov,项目名称:DataStudio,代码行数:25,代码来源:DocumentServer.cs

示例3: ReplaceMailMergeField

        private static void ReplaceMailMergeField(Dictionary<string, string> dictionary, Word.Document document, Word.Application word)
        {
            word.Visible = false;
            // обрабатываем верхний коллонтитул
            ProcessHeaderFooterFields(dictionary, Word.WdSeekView.wdSeekCurrentPageHeader, document, word);
            // обрабатываем нижний коллонтитул
            ProcessHeaderFooterFields(dictionary, Word.WdSeekView.wdSeekCurrentPageFooter, document, word);

            // обработка тела документа
            ProcessMainDocumentsFields(dictionary, document, word);
            //ProcessMainFields(dictionary, Word.WdSeekView.wdSeekMainDocument,document, word);

            if (document.ActiveWindow.ActivePane.View.SeekView != Word.WdSeekView.wdSeekMainDocument)
                document.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekMainDocument;

            word.Visible = true;
            word.Activate();
        }
开发者ID:Rukhlov,项目名称:DataStudio,代码行数:18,代码来源:DocumentServer.cs

示例4: Application_DocumentBeforeSave

        //--- Intercept save handler
        void Application_DocumentBeforeSave(Word.Document doc, ref bool SaveAsUI, ref bool Cancel)
        {
            //Check if this is one of our docs and if it is then do the right thing, not the black and white thing
            //Add a document property so we know that is a contract template and what the id is
            try
            {
                bool hidep = false;
                if (!Globals.ThisAddIn._p.IsVisible)
                {
                    Globals.ThisAddIn.ProcessingStart("Saving");
                    hidep = true;
                }

                string prop = GetCurrentAxiomDocProp();
                if (prop != null)
                {
                    string[] propa = prop.Split('|');
                    if (propa[0] == "ContractTemplate")
                    {
                        Globals.ThisAddIn.ProcessingUpdate("Save Contract Template");

                        // Get the Sidebar and save the elemnt value if that has changed
                        TemplateEdit.TEditSidebar tsb = Globals.ThisAddIn.GetTaskPaneControlTemplate(doc);
                        if(tsb!=null) tsb.FormSave();

                        //save this to a scratch file
                        Globals.ThisAddIn.ProcessingUpdate("Save Scratch");
                        string filename = Utility.SaveTempFile(propa[1]);
                        doc.SaveAs2(FileName: filename, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);

                        //Save a copy!
                        Globals.ThisAddIn.ProcessingUpdate("Save Copy");
                        string filenamecopy = Utility.SaveTempFile(propa[1] + "X");
                        Word.Document dcopy = Globals.ThisAddIn.Application.Documents.Add(filename, Visible: false);
                        dcopy.SaveAs2(FileName: filenamecopy, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);

                        var docclose = (Microsoft.Office.Interop.Word._Document)dcopy;
                        docclose.Close();
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(docclose);

                        //Now
                        Globals.ThisAddIn.ProcessingUpdate("Save To SalesForce");
                        _d.SaveTemplateFile(propa[1], filenamecopy);

                        //d.SaveTemplateXML(propa[1], doc.WordOpenXML);

                        //Cancel the save
                        SaveAsUI = false;
                        Cancel = true;
                    }

                    if (propa[0] == "ClauseTemplate")
                    {
                        //Save!
                        //doc = Globals.ThisAddIn.Application.ActiveDocument;
                        //d.SaveClauseXML(propa[1],doc.Content.Text ,doc.WordOpenXML);
                        Globals.ThisAddIn.ProcessingUpdate("Save Clause Template");
                        // doc = Globals.ThisAddIn.Application.ActiveDocument;

                        //save this to a scratch file
                        Globals.ThisAddIn.ProcessingUpdate("Save Scratch");
                        string filename = Utility.SaveTempFile(propa[1]);
                        doc.SaveAs2(FileName: filename, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);

                        //Save a copy!
                        Globals.ThisAddIn.ProcessingUpdate("Save Copy");
                        string filenamecopy = Utility.SaveTempFile(propa[1] + "X");
                        Word.Document dcopy = Globals.ThisAddIn.Application.Documents.Add(filename, Visible: false);
                        dcopy.SaveAs2(FileName: filenamecopy, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);

                        var docclose = (Microsoft.Office.Interop.Word._Document)dcopy;
                        docclose.Close();
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(docclose);

                        //Now save the file and then refresh any other docsto reflect the change
                        Globals.ThisAddIn.ProcessingUpdate("Save To SalesForce");
                        _d.SaveClauseFile(propa[1], doc.Content.Text, filenamecopy);

                        Globals.ThisAddIn.ProcessingUpdate("Update Any Templates with the clause");
                        RefreshAllTaskPanesWithClause(propa[1], doc.WordOpenXML);
                        doc.Activate();

                        //Cancel the save
                        SaveAsUI = false;
                        Cancel = true;
                    }

                    if (propa[0] == "Contract" || propa[0] == "UAContract")
                    {
                        //Save the doc and the data
                        GetTaskPaneControlContract().SaveContract(false,true);

                        //Cancel the save
                        SaveAsUI = false;
                        Cancel = true;
                    }

                    if (propa[0] == "Compare")
                    {
//.........这里部分代码省略.........
开发者ID:santoshsaha,项目名称:AxiomCS-Ribbon01,代码行数:101,代码来源:ThisAddIn.cs

示例5: UpdateContractConcept


//.........这里部分代码省略.........
                                    child.LockContentControl = false;
                                }
                            }

                            oldxml = cc.Range.WordOpenXML;

                            // OK having lots of problems with large paragraphs inserting into the content
                            // control - had a play manually and it worked when cutting and pasting
                            // *so* get the XML in a sepearate page and then get the formatted text and update
                            // this seems to fix it! need to do some more digging to see if there is a better way

                            Utility.UnlockContentControls(scratch);
                            scratch.Range(scratch.Content.Start, scratch.Content.End).Delete();
                            if (xml != "") scratch.Range(0).InsertXML(xml);

                            // if clauseid is blank then its a "select none" so do it even though the xml is blank
                            if (clauseid=="" || xml != "")
                            {
                                //cc.Range.InsertXML(xml);

                                //Track changes?
                                if (doc.TrackRevisions)
                                {

                                    // OK - gets more complicated! save the old paragraph to a scratch doc and undo any changes
                                    // then get the new one in another scratch doc - stop tracking changes in the current doc
                                    // do a diff and then insert that in the parra

                                    Word.Document oldclause=Globals.ThisAddIn.Application.Documents.Add(Visible: false);
                                    string oldclausefilename = Utility.SaveTempFile(doc.Name + "-oldclause");
                                    oldclause.Range().InsertXML(oldxml);

                                    // get rid of any changes - have to make it the active doc to do this
                                    oldclause.Activate();
                                    oldclause.RejectAllRevisions();

                                    MakeDropDownElementsText(oldclause);

                                    // Now update the elements of the scratch
                                    Utility.UnlockContentControls(scratch);
                                    UpdateElements(scratch, elementValues);
                                    // Dropdowns don't diff well (they show as changes, so change the content controls to text - they'll get changed back by initiate)
                                    MakeDropDownElementsText(scratch);

                                    // Now run a diff - do it from the old doc rather than a compare so it gives us the redline rather than blue line compare
                                    string scratchfilename = Utility.SaveTempFile(doc.Name + "-newclause");
                                    scratch.SaveAs2(FileName: scratchfilename, FileFormat: Word.WdSaveFormat.wdFormatXMLDocument, CompatibilityMode: Word.WdCompatibilityMode.wdCurrent);
                                    // this is how you do it as a pure compare - Word.Document compare = Application.CompareDocuments(oldclause, scratch,Granularity:Word.WdGranularity.wdGranularityCharLevel);

                                    oldclause.Compare(scratchfilename, CompareTarget: Word.WdCompareTarget.wdCompareTargetCurrent, AddToRecentFiles: false);
                                    oldclause.ActiveWindow.Visible = false;

                                    // Activate the doc - switch of tracking and insert the marked up dif
                                    doc.Activate();
                                    doc.TrackRevisions = false;

                                    // delete out what is there
                                    cc.Range.Delete();

                                    // delete out the styles!
                                    cc.Range.set_Style(Word.WdBuiltinStyle.wdStyleNormal);

                                    // delete out the pesky tables
                                    for (int tablesi = cc.Range.Tables.Count; tablesi > 0; tablesi--)
                                    {
                                        cc.Range.Tables[tablesi].Delete();
开发者ID:santoshsaha,项目名称:AxiomCS-Ribbon01,代码行数:67,代码来源:ThisAddIn.cs

示例6: App_NewDocument

        /*
                void App_NewDocument(Word.Document document)
                {
                    //System.Windows.Forms.MessageBox.Show("new doc");
                    log.Debug("New doc event fired.");
                    // new Microsoft.Office.Interop.Word.Document() doesn't make this fire!!!

                    //document.Activate();

                }
         */
        /// <summary>
        /// Create task pane if this docx contains
        /// XPaths & Conditions parts.
        /// </summary>
        /// <param name="document"></param>
        void App_DocumentOpen(Word.Document document)
        {
            // AutoExec macro (if present) and this event will both run,
            // but where there is an auto exec macro,
            // only if the user runs the AutoExec macro.
            // The AutoExec macro runs first, then this.

            log.Debug("App_DocumentOpen event fired.");
            //MessageBox.Show("App_DocumentOpen event fired.");

            if (OpenDoPEDetection.configIfPresent(document))
            {

                log.Debug("OpenDoPE detected");
                //MessageBox.Show("OpenDoPE detected");

                //Ribbon theRibbon = (Ribbon)Ribbon.getRibbon(); // doesn't work .. can't cast COM object
                myRibbon.enable(false);

                //app.WindowBeforeRightClick += new Word.ApplicationEvents4_WindowBeforeRightClickEventHandler(app_WindowBeforeRightClick);

            }
            else
            {
                //MessageBox.Show("OpenDoPE NOT detected!!");
            }

            document.Activate();

            // Set state to match this docx
            Ribbon.myInvalidate();

            log.Debug("Open event handler finished");
        }
开发者ID:plutext,项目名称:OpenDoPE-NoXML-WordAddIn,代码行数:50,代码来源:ThisAddIn.cs

示例7: CopyBuildingBlockLogic

        static void CopyBuildingBlockLogic(Word.Document document, Word.Range Range, FabDocxState fabDocxState)
        {
            System.Threading.Thread.Sleep(300);

            // We need to copy the logic over
            GlobalTemplateManager.GetGlobalTemplateManager().copyBuildingBlockLogic(document, Range);

            // If its being copied into a repeat, either:
            // 1. tell them sorry, can't be done; or
            // 2. move the repeated variables (and xpaths..) into that repeat!

            document.Activate();

            if (fabDocxState.TaskPane.Visible)
            {
                Controls.LogicTaskPaneUserControl ltp = (Controls.LogicTaskPaneUserControl)fabDocxState.TaskPane.Control;
                ltp.populateLogicInUse();
            }
        }
开发者ID:plutext,项目名称:OpenDoPE-NoXML-WordAddIn,代码行数:19,代码来源:Ribbon.cs


注:本文中的Microsoft.Office.Interop.Word.Activate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。