VBA问题,如何判断word文本的最后一个字符?或换行符?
1个回答
展开全部
Sub CheckSelction()
With Selection
If .Type = wdSelectionIP Then
If .Start = 0 Then
MsgBox "光标位于文档首"
ElseIf .Start = ActiveDocument.Content.End - 1 Then
MsgBox "光标位于文档末"
ElseIf .Characters(1) = Chr(13) Then
MsgBox "光标位于段尾"
ElseIf .Start = .Paragraphs(1).Range.Start Then
MsgBox "光标位于段首"
ElseIf .Information(wdFirstCharacterColumnNumber) = 1 Then
MsgBox "光标位于行首"
ElseIf .Characters(1).Information(wdFirstCharacterColumnNumber) = 1 Then
MsgBox "光标位于行末"
Else
MsgBox "光标位段落中"
End If
End If
End With
End Sub
With Selection
If .Type = wdSelectionIP Then
If .Start = 0 Then
MsgBox "光标位于文档首"
ElseIf .Start = ActiveDocument.Content.End - 1 Then
MsgBox "光标位于文档末"
ElseIf .Characters(1) = Chr(13) Then
MsgBox "光标位于段尾"
ElseIf .Start = .Paragraphs(1).Range.Start Then
MsgBox "光标位于段首"
ElseIf .Information(wdFirstCharacterColumnNumber) = 1 Then
MsgBox "光标位于行首"
ElseIf .Characters(1).Information(wdFirstCharacterColumnNumber) = 1 Then
MsgBox "光标位于行末"
Else
MsgBox "光标位段落中"
End If
End If
End With
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |