发布时间:2019-12-02编辑:佚名阅读(1527)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Tools.Ribbon; using Word = Microsoft.Office.Interop.Word; namespace WordInsertStringBeforeCursor { public partial class Ribbon1 { private void Ribbon1_Load(object sender, RibbonUIEventArgs e) { } private void button1_Click(object sender, RibbonControlEventArgs e) { Word.Application objApplication = Globals.ThisDocument.Application; Word.Selection objSelection = objApplication.Selection; Word.Range objRange = objSelection.Range; objRange.InsertAfter("Test"); objRange.Collapse(Word.WdCollapseDirection.wdCollapseEnd); objRange.Select(); } } }
1人
0人
0人
0人