2011-10-20 162 views
2

如何在VBA脚本中使用Selection对象从Word文档获取一行?事情是这样的:使用选择对象(vba)从word文档获取一行

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

编辑:当我这样做:

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

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

回答

6

您需要展开的选择:

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