使用C#将光标移动到MsWord中“文本"的末尾吗? [英] Move my cursor to the end of the Text in MsWord using C#?

查看:291
本文介绍了使用C#将光标移动到MsWord中“文本"的末尾吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题听起来很简单,但我找不到任何解决方案.我想做的是将MsWord中的光标位置"移动到文本末尾.我的代码如下

This question might sound very simple but I am unable to find any Solution for it.What I am trying to do is to Move my Cursor Positon in MsWord to the end of the text.My code is as follows

  object StartPos = 0;
  object Endpos = 1;
  Microsoft.Office.Interop.Word.Range rng= oDoc.Range(ref StartPos, ref Endpos);
  rng.Text = "This is first line Word from C#";

输出为

这是C#中的第一行Word

I This is first line Word from C#

但是我想要这样的东西

这是C# I

谢谢所有

推荐答案

非常感谢大家的答复,我似乎已经找到了一个简单的解决方案.我试图修改Hassan的解决方案.现在我已经找到了

Well thank you all for your response I seem to have figured out a simple Solution.I tried to modify Hassan's Solution.There might be a much easier approach but as of now I have Found This

object NewEndPos = rng.StoryLength-1;
        rng = oDoc.Range(ref NewEndPos, ref NewEndPos);
        rng.Select();

这篇关于使用C#将光标移动到MsWord中“文本"的末尾吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆