Mở file Word , bấm tổ hợp phím Alt-F11 để mở cửa sổ Microsoft Visual Basic .
Bấm menu Insert > Module , bạn sao chép nội dung chữ đậm màu Tím bên dưới
Sub BigCardText()
Dim sDigits As String
Dim sBigStuff As String
sBigStuff = \"\"
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdMove
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
sDigits = Trim(Selection.Text)
If Val(sDigits) > 999999 Then
If Val(sDigits) <= 999999999 Then
sBigStuff = Trim(Int(Str(Val(sDigits) / 1000000)))
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, Text:=\"= \" + sBigStuff + \" \\* CardText\", _
PreserveFormatting:=True
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
sBigStuff = Selection.Text & \" million \"
sDigits = Right(sDigits, 6)
End If
End If
If Val(sDigits) <= 999999 Then
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, Text:=\"= \" + sDigits + \" \\* CardText\", _
PreserveFormatting:=True
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
sDigits = sBigStuff & Selection.Text
Selection.TypeText Text:=sDigits
Selection.TypeText Text:=\" \"
Else
MsgBox \"Number too large\", vbOKOnly
End If
End Sub
Quay trở lại Word .
Bạn bôi đen số cần chuyển đổi , chọn menu Developer > Macro , bấm macro có tên là BigCardText
Nếu như bạn thường xuyên phải dùng tính năng này thì có thể tạo nút bấm trên thanh công cụ bằng cách như sau .
Bấm chọn Customize Quick Access Toolbar > More Command
Chọn Macro trong phần Choose commands from , bạn sẽ thấy tên macro của mình là BigCardText , chọn Add .
Bạn có thể thay đổi biểu tượng của Macro này bằng Modify
Khi ấy bạn sẽ thấy biểu tượng này trên thanh công cụ và sử dụng