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

时间:2011-10-20 12:03:28

标签: vba

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

Selection.MoveDown Unit:=wdLine, Count:=15
'print the 15th line here

编辑:当我这样做时:

Selection.MoveDown Unit:=wdLine, Count:=15
MsgBox (Selection.Text)

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

1 个答案:

答案 0 :(得分:7)

您需要扩展选择:

Selection.MoveDown Unit:=wdLine, Count:=15
Selection.Expand wdLine
MsgBox (Selection.Text)