VBA问题,如何判断word文本的最后一个字符
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
怎样使用VBA批量删除word中空行
Sub DelBlank()Dim i As Paragraph, n As IntegerApplication.ScreenUpdating = FalseFor Each i In ActiveDocument.ParagraphsIf Len(i.Range) = 1 Theni.Range.Deleten = n + 1End IfNextMsgBox "共删除空白段落" & n & "个"Application.ScreenUpdating = TrueEnd Sub试试上面的代码。
转载请注明出处51数据库 » vbaword换行符