【问题标题】:C# Select text between caret and end of the document in WordC#在Word中选择插入符号和文档末尾之间的文本
【发布时间】:2017-11-26 15:28:16
【问题描述】:

我正在尝试让程序在 Word 中选择插入符号和文档结尾之间的所有文本。 它应该是这样的:

app.ActiveDocument.Range(Selection, EndOdDocument).Select();

Selection 应该是插入符号的位置,EndOfDocument - 文档的结尾。 然而,经过几个小时的尝试,我无法解决这个问题,尽管解决方案可能非常明显。

【问题讨论】:

    标签: c# ms-word range selection caret


    【解决方案1】:

    大概是这样的:

    app.Selection.End = app.ActiveDocument.Content.End;
    

    但是,无需更改选择即可获取文本:

    var doc = app.ActiveDocument;
    string text = doc.Range(app.Selection.Start, doc.Content.End).Text;
    

    【讨论】:

    • 天啊,我知道这很明显!谢谢!
    猜你喜欢
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-06
    • 1970-01-01
    • 2022-10-04
    • 2019-05-14
    相关资源
    最近更新 更多