根据我的评论,Word 模型没有“Line”对象。但是...... selection.move 有一个 units:=WdUnits.Line 参数来逐行移动选择......(谷歌告诉我)
那么你可以这样做(免责声明:它很粗糙,准备好了,可能不健壮)
' select the found text and go up one line and collapse the selection to the end
' that gives you the starting position of the next line of text
' that's the line that has the fount text
rng.Select
Selection.Move(Unit:=WdUnits.wdLine, Count:=-1)
Selection.Collapse(WdCollapseDirection.wdCollapseEnd)
Dim startPos As Integer = Selection.End
' Now do same for the end position of the line of text that has the found text
rng.Select()
Selection.Move(Unit:=WdUnits.wdLine, Count:=1)
Selection.Collapse(WdCollapseDirection.wdCollapseStart)
Dim endPos As Integer = Selection.Start
Selection.SetRange(startPos, endPos)
Selection.Select()
下面是一个示例,其中我搜索了“嵌入”一词并选择了第 2 行: