如何在word中使用VBA得出每一页都多少行文字啊?
2个回答
展开全部
Sub LinesOfPage()
'方法很简单,就是数
Dim PageNo As Integer, Lines As Integer, MovedLines As Integer
'先确定现在的页码
PageNo = Selection.Information(wdActiveEndAdjustedPageNumber)
'行计数清零
Lines = 0
Do
'向上挪一行,如果到头了没挪动或挪到上一页去了就停止
If Selection.Move(wdLine, -1) = 0 Or PageNo <> Selection.Information(wdActiveEndAdjustedPageNumber) Then Exit Do
'还在同一页行数加1,继续挪
Lines = Lines + 1
Loop
'向下挪回开始的位置
Selection.Move wdLine, Lines
Do
'现在开始向下挪,,如果到尾了没挪动或挪到下一页去了就停止
If Selection.Move(wdLine, 1) = 0 Or PageNo <> Selection.Information(wdActiveEndAdjustedPageNumber) Then Exit Do
'还在同一页行数加1,继续挪
Lines = Lines + 1
Loop
'最后Lines就是这页的行数
End Sub
'方法很简单,就是数
Dim PageNo As Integer, Lines As Integer, MovedLines As Integer
'先确定现在的页码
PageNo = Selection.Information(wdActiveEndAdjustedPageNumber)
'行计数清零
Lines = 0
Do
'向上挪一行,如果到头了没挪动或挪到上一页去了就停止
If Selection.Move(wdLine, -1) = 0 Or PageNo <> Selection.Information(wdActiveEndAdjustedPageNumber) Then Exit Do
'还在同一页行数加1,继续挪
Lines = Lines + 1
Loop
'向下挪回开始的位置
Selection.Move wdLine, Lines
Do
'现在开始向下挪,,如果到尾了没挪动或挪到下一页去了就停止
If Selection.Move(wdLine, 1) = 0 Or PageNo <> Selection.Information(wdActiveEndAdjustedPageNumber) Then Exit Do
'还在同一页行数加1,继续挪
Lines = Lines + 1
Loop
'最后Lines就是这页的行数
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |