Exemple #1
0
 internal static Microsoft.Office.Interop.Word.Document GetWordEditor(Outlook.Inspector inspector)
 {
     // https://docs.microsoft.com/zh-tw/office/vba/api/outlook.inspector.wordeditor
     // The WordEditor property is only valid if the IsWordMail method returns True and the EditorType property is olEditorWord.
     if (inspector.IsWordMail() && inspector.EditorType == Outlook.OlEditorType.olEditorWord)
     {
         return(inspector.WordEditor as Microsoft.Office.Interop.Word.Document);
     }
     else
     {
         return(null);
     }
 }
Exemple #2
0
        public void StartSpellChecking()
        {
            Cursor.Current = Cursors.WaitCursor;

            Globals.ThisAddIn.SpellOn = true;
            ResetAllInitVariables();

            if (!tabControl.TabPages.Contains(tabPage1))
            {
                tabControl.TabPages.Add(tabPage1);
            }
            tabControl.SelectTab(tabPage1);

            m_Inspector = Globals.ThisAddIn.Application.ActiveInspector();
            m_Document  = m_Inspector.WordEditor;
            if (!m_Inspector.IsWordMail())
            {
                m_Document = m_Inspector.CurrentItem as Word.Document;
            }

            // get the cursor position in the document
            nCursorPos = m_Document.Application.Selection.Start;
            // get all shapes in the document
            oShapes = m_Document.Application.ActiveDocument.Shapes;

            Word.ShapeRange oShpRng = m_Document.Application.Selection.ShapeRange;
            if (oShpRng.Count > 0)
            {
                object     obj = 1;
                Word.Shape shp = oShpRng.get_Item(ref obj);
                bCheckNormalText = false;
                bCursorInShape   = true;

                for (int i = 1; i <= oShapes.Count; i++)
                {
                    obj         = i;
                    nShapeIndex = i;
                    Word.Shape oShp = oShapes.get_Item(ref obj);
                    if (oShp.Name == shp.Name)
                    {
                        break;
                    }
                }
            }
            RestartParagraph();
            SetSpellingState("Անտեսել");
        }
Exemple #3
0
 void Inspectors_RegisterEventWordDocument(Outlook.Inspector inspector)
 {
     Outlook.MailItem mailItem = inspector.CurrentItem as Outlook.MailItem;
     if (mailItem != null)
     {
         // Check that the email editor is Word editor
         // Although "always" is a Word editor in Outlook 2013, it's best done perform this check
         if (inspector.EditorType == Outlook.OlEditorType.olEditorWord && inspector.IsWordMail())
         {
             // Get the Word document
             Word.Document document = inspector.WordEditor;
             if (document != null)
             {
                 // Subscribe to the BeforeDoubleClick event of the Word document
                 document.Application.WindowBeforeDoubleClick +=
                     new Word.ApplicationEvents4_WindowBeforeDoubleClickEventHandler(
                         ApplicationOnWindowBeforeDoubleClick);
             }
         }
     }
 }
Exemple #4
0
        /// <summary>Performs search highlighting in an open mail item.
        /// </summary>
        /// <param name="inspector">The inspector for the open item.</param>
        /// <param name="searchText">The text to highlight.</param>
        private void FindInInspector(Outlook.Inspector inspector, string term)
        {
            if (inspector == null || string.IsNullOrWhiteSpace(term))
            {
                return;
            }

            if (inspector.IsWordMail())
            {
                Word.Document doc = inspector.WordEditor as Word.Document;

                Word.Range wdRange = doc.Application.Selection.Range;

                Word.Find wdFind = wdRange.Find;
                wdFind.Format         = false;
                wdFind.MatchCase      = false;
                wdFind.MatchWholeWord = false;

                wdFind.HitHighlight(term,
                                    HighlightColor: Word.WdColor.wdColorYellow);
            }
        }