gpt4 book ai didi

c# - 修改使用 InsertParagraphAfter() 添加的段落

转载 作者:行者123 更新时间:2023-11-30 22:30:37 27 4
gpt4 key购买 nike

var p1 = document.Paragraphs.Add(ref o);
p1.Range.InsertParagraphAfter();

现在我想获取刚刚使用 InsertParagraphAfter() 创建的段落并对其进行修改。我怎样才能访问它?

最佳答案

InsertParagraphAfter 应该扩展当前选择以包括新段落。因此,如果您首先在现有段落的末尾创建一个空选择,则当前选择应在调用 InsertParagraphAfter 后设置为新段落。

请注意,我还没有测试以下代码(我什至没有尝试编译它),所以我可能离题太远了。

var p1 = document.Paragraphs.Add(ref o);    
// Set the selection to the end of the paragraph.
document.Range(p1.Range.End, p1.Range.End).Select();
p1.Range.InsertParagraphAfter();
// InsertParagraphAfter should expand the active selection to include
// the newly inserted paragraph.
var newParagraph = document.Application.Selection;

关于c# - 修改使用 InsertParagraphAfter() 添加的段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9603597/

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