- Sub 人民币中文大写转阿拉伯数字()
- Dim n As Long, i As String, j As String
- If MsgBox("阿拉伯数字是否放在大写前面?(否则后面)", vbYesNo + vbExclamation, "人民币中文大写转阿拉伯数字") = vbYes Then n = 1 Else n = 0
- ActiveDocument.Content = ActiveDocument.Content & "`"
- Selection.HomeKey Unit:=wdStory
- Do
- Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
- If Selection = "`" Then Exit Do
- Do While Selection.Characters.Last Like "[壹贰叁肆伍陆柒捌玖零亿万仟佰拾元圆角分整]"
- Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
- If Selection.Characters.Last Like "[!壹贰叁肆伍陆柒捌玖零亿万仟佰拾元圆角分整]" Then
- Selection.MoveEnd Unit:=wdCharacter, Count:=-1
- If Selection Like "元*" Then Selection.MoveStart Unit:=wdCharacter, Count:=1
- '
- Selection.Font.Bold = True '加粗
- Selection.Font.Color = wdColorBlue '蓝色
- Selection.Font.Underline = wdUnderlineWavyHeavy '重波浪线
- '
- i = Selection.Text
- i = Replace(i, "圆", "元")
- i = Replace(i, "拾元", "0.")
- If i Like "*仟元整" Then i = Replace(i, "仟元整", "000")
- If i Like "*仟元零*" Then i = Replace(i, "仟元零", "000.")
- If i Like "*零?角*" Then i = Replace(i, "零", "")
- If i Like "*角" Then i = Replace(i, "角", "0")
- If i Like "*元整" Then i = Replace(i, "元整", "")
- i = Replace(i, "壹", "1")
- i = Replace(i, "贰", "2")
- i = Replace(i, "叁", "3")
- i = Replace(i, "肆", "4")
- i = Replace(i, "伍", "5")
- i = Replace(i, "陆", "6")
- i = Replace(i, "柒", "7")
- i = Replace(i, "捌", "8")
- i = Replace(i, "玖", "9")
- i = Replace(i, "零", "0")
- i = Replace(i, "亿", "")
- i = Replace(i, "万", "")
- i = Replace(i, "仟", "")
- i = Replace(i, "佰", "")
- i = Replace(i, "拾", "")
- i = Replace(i, "元", ".")
- i = Replace(i, "角", "")
- i = Replace(i, "分", "")
- i = Replace(i, "整", "")
- j = "(¥:" & i & "元)"
- If n = 1 Then Selection.InsertBefore Text:=vbCr & j Else Selection.InsertAfter Text:=j & vbCr
- Exit Do
- End If
- Loop
- Selection.MoveRight Unit:=wdCharacter, Count:=1
- Loop
- Selection.Delete: Selection.TypeBackspace
- End Sub
复制代码 |