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


C# Document.Select方法代码示例

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


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

示例1: CopyBody

        private void CopyBody(AppointmentItem ai, MailItem mailItem)
        {
            ThisAddIn.g_log.Info("Copy AppointmentItem body to MailItem enter");
            Word.Document Doc = new Word.Document();
            Word.Document Doc2 = new Word.Document();
            Word.Application App1;
            Word.Selection Sel;
            Doc = ai.GetInspector.WordEditor as Word.Document;
            Word.Application App2;
            Word.Selection Sel2;

            if (Doc != null)
            {
                ThisAddIn.g_log.Info(string.Format("appointmentItem doc length is {0}.", Doc.Content.Text.Length));
                Doc.Activate();
                Doc.Select();
                App1 = Doc.Windows.Application;
                Sel = App1.Selection;
                Sel.WholeStory();
                Sel.Copy();

                Doc2 = mailItem.GetInspector.WordEditor as Word.Document;
                if (Doc2 != null)
                {
                    Doc2.Activate();
                    Doc2.Select();
                    App2 = Doc2.Windows.Application;
                    Sel2 = App2.Selection;
                    Sel2.WholeStory();

                    try
                    {
                        Sel2.PasteAndFormat(WdRecoveryType.wdPasteDefault);
                    }
                    catch (System.Exception ex)
                    {
                        ThisAddIn.g_log.Error(string.Format("copy to body exception, {0}", ex.ToString()));
                    }

                    mailItem.Save();
                    ThisAddIn.g_log.Info(string.Format("mailItem doc length is {0}.", Doc2.Content.Text.Length));

                    if (mailItem.Body == null || mailItem.Body.Length < 100)
                    {
                        Doc2.Activate();
                        ((_Inspector)(mailItem.GetInspector)).Activate();
                    }
                }
            }

            Doc = null;
            Doc2 = null;
            App1 = null;
            App2 = null;
            Sel = null;
            Sel2 = null;
            ThisAddIn.g_log.Info("Copy AppointmentItem body to MailItem exit");
        }
开发者ID:eSDK,项目名称:esdk_OutlookPlugin,代码行数:58,代码来源:ThisAddIn.cs

示例2: CopyBodyToMeeting

        private void CopyBodyToMeeting(AppointmentItem ai, ref MeetingItem meetingItem)
        {
            ThisAddIn.g_log.Info("Copy AppointmentItem body to MeetingItem enter");
            Word.Document Doc = new Word.Document();
            Word.Document Doc2 = new Word.Document();
            Word.Application App1;
            Word.Selection Sel;

            Doc = ai.GetInspector.WordEditor as Word.Document;

            if (Doc != null)
            {
                ThisAddIn.g_log.Info(string.Format("appointmentItem doc length is {0}.", Doc.Content.Text.Length));
                Doc.Activate();
                Doc.Select();
                App1 = Doc.Windows.Application;
                Sel = App1.Selection;
                Sel.WholeStory();
                Sel.Copy();

                Doc2 = meetingItem.GetInspector.WordEditor as Word.Document;
                if (Doc2 != null)
                {
                    Doc2.Activate();
                    object start = 0;
                    Range newRang = Doc2.Range(ref start, ref start);

                    int ioo = Doc2.Sections.Count;
                    Section sec = Doc2.Sections[1];

                    sec.Range.InsertBreak(Type.Missing);//插入换行符
                    sec.Range.PasteAndFormat(WdRecoveryType.wdPasteDefault);

                    meetingItem.Save();
                    ThisAddIn.g_log.Info(string.Format("meetingItem doc length is {0}.", Doc2.Content.Text.Length));
                    //ThisAddIn.g_log.Info(string.Format("mailItem body length is {0}.", meetingItem.Body.Length));

                    if (meetingItem.Body == null || meetingItem.Body.Length < 100)
                    {
                        Doc2.Activate();
                        ((_Inspector)(meetingItem.GetInspector)).Activate();
                    }
                }
            }
            Doc = null;
            Doc2 = null;
            App1 = null;
            Sel = null;

            ThisAddIn.g_log.Info("Copy AppointmentItem body to MeetingItem exit");
        }
开发者ID:eSDK,项目名称:esdk_OutlookPlugin,代码行数:51,代码来源:ThisAddIn.cs


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