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



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

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

编辑:当我做:

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

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

你需要展开选区:

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

最新更新