kerrypnx
8/30/2018 - 10:22 AM

标题加点

revise 8-30

Sub addSpaceForTitle()
    With Selection.Paragraphs(1).Range
        Set myrange = ActiveDocument.Range(.Start, .Start + InStr(.Text, " "))
        myrange.Select
        Do While IsNumeric(Selection.Range.Next.Text)
        
            Selection.MoveRight wdCharacter, 1, wdExtend
        Loop
        
        If IsNumeric(myrange.Characters(1)) Then
            If FunctionGroup.existWord(myrange.Text) Then
                
                Selection.HomeKey wdLine
                Selection.MoveEndWhile ("123456789. ")
                Selection.Collapse wdCollapseEnd
                
                
            Else
           Selection.Text = Replace(Selection.Text, " ", "")
                Selection.Collapse wdCollapseEnd
                If IsNumeric(Selection.Text) Then
                
                Selection.MoveLeft wdCharacter, 1
                End If
            End If
            If Selection.Previous.Text <> "." Then
            Selection.InsertAfter "."
            End If
            
            If Selection.Next <> " " Then
            
                Selection.InsertAfter " "
            End If
        End If
    End With
    
End Sub