以前见过的人民币大写转换函数都是EXCEL版本的,好象高手们都对WORD大写转换都不感兴趣,其实作为经济工作者,或是与制式合同打交道的财务人员,应该说还是经常会接触到小写金额转人民币大写的问题,如能有相应快速转换办法,亦能小提工作效率。本人愚笨,写了个小程序,还请高手指点。
Sub 人民币大写()
Dim Seltxt As String
Dim Zx As Double, Xx As Double
Dim Selcase As String
Seltxt = Selection.Text
Zx = Int(Val(Seltxt))
Xx = (Round(Val(Seltxt), 2) - Zx) * 100
Gxs = "= " + Str(Zx) + " \* Chinesenum2"
Selection.Moveright Unit:=Wdcharacter, Count:=1
Set Ym = Selection.Fields.Add(Range:=Selection.Range, Text:=Gxs)
Selcase = Ym.Result + "元"
Gxs = "= " + Str(Xx) + " \* Chinesenum2"
Set Ym = Selection.Fields.Add(Range:=Selection.Range, Text:=Gxs)
Xxcase = Ym.Result
Selection.Moveleft Unit:=Wdcharacter, Count:=2, Extend:=Wdextend
Selection.Delete
Select Case Xx
Case 0
Selcase = Selcase + "整"
Case 1 To 9
Selcase = Selcase + "零" + Xxcase + "分"
Case 10 To 99
If (Xx Mod 10) = 0 Then
Selcase = Selcase + Left(Xxcase, 1) + "角整"
Else
Selcase = Selcase + Left(Xxcase, 1) + "角" + Right(Xxcase, 1) + "分"
End If
End Select
Selection.Text = Selcase
End Sub
[此贴子已经被作者于2004-3-10 21:33:50编辑过] |