|
- Sub 人民币中文大写()
- Dim i$, j$, k&, s&, v&
- With Selection
- If .Type = wdSelectionIP Then MsgBox "请选定数字!", 0 + 16: End
- Do While .Text Like "[!0-9.]*"
- .MoveStart 1, 1
- Loop
- Do While .Text Like "*[!0-9]"
- .MoveEnd 1, -1
- Loop
- v = Len(.Text)
- .Characters(1).Select
- Do While .Next Like "[0-9.]"
- .MoveEnd 1, 1
- s = s + 1
- If s = v - 1 Then Exit Do
- Loop
- If .Text Like "*.*" Then
- i = Format(.Text, "0.00")
- j = Right(i, 2)
- i = Left(i, Len(i) - 3)
- k = 1
- Else
- i = .Text
- End If
- .TypeText Text:="(人民币"
- .Fields.Add Range:=.Range, Text:="= " & i & " \* CHINESENUM2"
- .TypeText Text:="元"
- If k = 0 Then
- .TypeText Text:="整)"
- Else
- .Fields.Add Range:=.Range, Text:="= " & Left(j, 1) & " \* CHINESENUM2"
- .TypeText Text:="角"
- .Fields.Add Range:=.Range, Text:="= " & Right(j, 1) & " \* CHINESENUM2"
- .TypeText Text:="分)"
- End If
- .Paragraphs(1).Range.Fields.Unlink
- End With
- End Sub
复制代码 |
|