slogan 专业知识问答平台!
佰学网 >生活问答 > 知识 > 怎么用wordxa0VBA统计光标所在行的字符数

怎么用wordxa0VBA统计光标所在行的字符数

原创 2022-03-07 14:39:13
SubMacro2()Dimr,p,r0,p0,rr,ppp=Selection.. 精选答案
  • 问题相关
Sub Macro2()
Dim r, p, r0, p0, rr, pp
p= Selection.Information(wdActiveEndPageNumber) '当前页码
r= Selection.Information(wdFirstCharacterLineNumber) '当前行

'数行数
p0 = p
rr = r
Do
Selection.MoveDown Unit:=wdLine, Count:=1
pp = Selection.Information(wdActiveEndPageNumber)
r0 = Selection.Information(wdFirstCharacterLineNumber)
If pp > p Then
'退回原处
Selection.MoveUp Unit:=wdLine, Count:=(rr - r + 1)
Exit Do
End If
If rr = r0 Then
'退回原处
Selection.MoveUp Unit:=wdLine, Count:=(rr - r)
Exit Do
End If
rr = r0
Loop
MsgBox "当前页码:" & p & vbCrLf & "本页总行数:" & rr
End Sub

©本文版权归作者所有,任何形式转载请联系我们:xiehuiyue@offercoming.com。

相关内容推荐

来自百学网

刘老师

刘老师

中国人大教育学硕士

关注

你可能关心