gpt4 book ai didi

c#如何将光标设置在插入文本之前的末尾

转载 作者:太空宇宙 更新时间:2023-11-03 14:46:55 24 4
gpt4 key购买 nike

我在 Word 文档的随机位置插入了一些动态文本,之后需要光标正好位于该文本的末尾(不是文档末尾!)。此时光标停留在之前的位置,即插入文本的开头。

我认为这里没有太多有用的代码可以显示......我只是将一些 html 复制到一个文件中并将其插入到文档中:

          string tmp = AppDomain.CurrentDomain.BaseDirectory + "tmp.html";
using (StreamWriter file = new StreamWriter(tmp))
{
file.Write(report, 0, report.Length);
}

var currentCursorPosition = Globals.ThisAddIn.Application.Selection.Range;
currentCursorPosition.InsertFile(tmp);

最佳答案

我建议您使用 Microsoft.Office.Interop.Word 库。你可以通过它移动光标到word文档的末尾。使用这个:Move my cursor to the end of the Text in MsWord using C#?

关于c#如何将光标设置在插入文本之前的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53811622/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com