VSTO 向office文档中插入内容

原文: VSTO 向office文档中插入内容

Word:

            Word.Selection sec = ThisAddIn.appWord.Selection;
            sec.InsertAfter(value);

Excel:

            Excel.Workbook wbook = Globals.ThisAddIn.Application.ActiveWorkbook;  //当前活动workbook
            Excel.Worksheet wsheet = (Excel.Worksheet)wbook.ActiveSheet;          //当前活动sheet           
            Excel.Range range = wsheet.Application.ActiveCell;       //当前活动的cell
            value = range.Text + " " + value;
            range.set_Value(Type.Missing, value); 

Outlook:

           Word.Document document1 = this.inspector.WordEditor;
           document1.Application.Selection.InsertAfter(value);

你可能感兴趣的:(Office)