使用Selection对象从word文档中获取一行(vba)

bad*_*ash 2 vba

如何使用VBA脚本中的Selection对象从word文档中获取一行?像这样的东西:

Selection.MoveDown Unit:=wdLine, Count:=15
'print the 15th line here
Run Code Online (Sandbox Code Playgroud)

编辑:当我这样做:

Selection.MoveDown Unit:=wdLine, Count:=15
MsgBox (Selection.Text)
Run Code Online (Sandbox Code Playgroud)

它只打印该行的第一个字符.

Fio*_*ala 7

您需要扩展选择:

Selection.MoveDown Unit:=wdLine, Count:=15
Selection.Expand wdLine
MsgBox (Selection.Text)
Run Code Online (Sandbox Code Playgroud)