如何在word表格中用VBA得到当前光标所在得单元格得位置
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询