|
Sub gotoSection_end_main()
Dim doc As Document, Rng As Range, SecCount%, RevCount%, SecNum%
Set doc = ActiveDocument
With ActiveWindow.View.RevisionsFilter
.Markup = wdRevisionsMarkupAll
.View = wdRevisionsViewFinal
End With
SecCount = doc.Sections.Count
SecNum = 1
If SecCount = 1 Then
Selection.EndKey wdStory '如果只有一节,光标定位到文末
Else
Do While SecNum < SecCount + 1
If gotoSection_end(SecNum) Then Exit Do
SecNum = SecNum + 1
Loop
End If
With ActiveWindow.View.RevisionsFilter
.Markup = wdRevisionsMarkupSimple
.View = wdRevisionsViewFinal
End With
End Sub
Function gotoSection_end(n)
Dim doc As Document, Rng As Range, Findit As Boolean
Set doc = ActiveDocument
With doc.Sections(n)
If Len(.Range) > 1 Then
Set Rng = doc.Range(.Range.End - 1, .Range.End - 1)
If Rng.Characters.First.Previous.Text = Chr(13) Then Rng.Move wdCharacter, -1
If Rng.Revisions.Count = 0 Then
Rng.Select
Findit = True
End If
Else
msgbox "首节除分节符外无其它内容,无法定位,光标返回首页。"
Selection.HomeKey wdStory
Findit = True
End If
End With
gotoSection_end = Findit
End Function
再试 |
|