我的目标是将一些文本插入到键盘光标所在的活动行的word文档中。我能够在一个特定的书签之后插入它,但是我想让用户能够在他想要的地方插入它。
目前,我正在使用以下代码:
Word.Application oWordApp;
Word.Document oWordDoc;
oWordApp = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
oWordDoc = oWordApp.ActiveDocument;
object docAction = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark;
object docTarget = "TextBegin";
object n = Type.Missing;
oWordApp.Selection.GoTo(ref docAction, ref n, ref n, ref docTarget);
oWordApp.Selection.InsertAfter("Test");现在,我正在搜索一个获取当前选定行的方法,因此我可以使用:
object docAction = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToLine我所发现的只是获取两个对象之间的范围,或者转到具体的行/行。
有人能告诉我我要做什么或者我要找什么吗?
发布于 2014-07-14 11:29:21
在你的代码中,你已经有了它。oWordApp.Selection是当前选定的范围或插入点。
https://stackoverflow.com/questions/24735401
复制相似问题