|
守版的代码:
Sub 千分位格式()
Dim i As Range, Acell As Cell, CR As Range, YN As String
On Error Resume Next
Application.ScreenUpdating = False
With Selection
If .Type = 2 Then
If .Words(1) Like "#" = False Then .Words(1).InsertBefore "辅助"
For Each i In .Words
If i Like "####*" = True Then
If i.Next Like "." = True And i.Next(wdWord, 2) Like "#*" = True Then
i.SetRange Start:=i.Start, End:=i.Next(wdWord, 2).End
i = Format(i, "Standard")
Else
i = Format(i, "Standard")
End If
End If
Next i
.Words(1).Delete
ElseIf .Type = 5 Then
For Each Acell In .Cells
Set CR = ActiveDocument.Range(Acell.Range.Start, Acell.Range.End - 1)
If CR Like "####*" = True Then
If CR Like "####.#*" = True Then
YN = Format(CR, "Standard")
CR.Text = YN
Else
YN = Format(CR, "Standard")
CR.Text = YN
End If
End If
Next Acell
Else
MsgBox "您只能选定文本或者表格之一!", vbOK + vbInformation
End If
End With
Application.ScreenUpdating = True
End Sub |
|