VBA问题,如何判断word文本的最后一个字符?或换行符?
答案:1 悬赏:40 手机版
解决时间 2021-02-19 08:15
- 提问者网友:留有余香
- 2021-02-18 20:15
VBA问题,如何判断word文本的最后一个字符?或换行符?
最佳答案
- 五星知识达人网友:醉吻情书
- 2021-02-18 20:54
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
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯