应chengxiang要求,第三次修订,请检验: Sub 人民币大写() Dim seltxt As String Dim zx As Double, xx As Double Dim selcase As String seltxt = Selection.Text If Val(seltxt) < 0 Then selcase = "红书" Else selcase = "" End If zx = Int(Abs(Val(seltxt))) xx = Int((Round(Abs(Val(seltxt)), 2) - zx) * 100) Selection.MoveRight Unit:=wdCharacter, Count:=1 If zx <> 0 Then gxs = "= " + Str(zx) + " \* CHINESENUM2" Set ym = Selection.Fields.Add(Range:=Selection.Range, Text:=gxs) selcase = selcase + ym.Result + "元" Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.TypeBackspace Selection.Delete End If gxs = "= " + Str(xx) + " \* CHINESENUM2" Set ym = Selection.Fields.Add(Range:=Selection.Range, Text:=gxs) xxcase = ym.Result Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.TypeBackspace 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
[此贴子已经被konggs于2007-6-11 23:38:15编辑过] |