|
楼主 |
发表于 2017-5-20 15:26
|
显示全部楼层
本帖最后由 weiyingde 于 2017-5-20 21:33 编辑
如果逐行录入文本的话,还可以用如下代码实现:
Sub 逐行选取文本()
dim arr()
Selection.HomeKey Unit:=wdStory
For x = 1 To ActiveDocument.BuiltInDocumentProperties(wdPropertyLines).Value
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
n =n +1
redim preserve arr(1 to n)
arr(n)=selection.range.text
Selection.MoveDown Unit:=wdLine, Count:=1
Next
End Sub
选择一行的VBA语句为
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
删除一行的VBA语句为
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdLine
|
|