مواقعی وجود دارد که لازم است اعداد را به درستی هجی کنید. به عنوان مثال، ممکن است بخواهید "1234" را به صورت "هزار و دویست و سی و چهار" بنویسید. Word هیچ عملکرد داخلی ندارد که تبدیل را برای شما انجام دهد، بنابراین شما باید یک ماکرو ایجاد کنید که تبدیل را مدیریت کند.
ماکرو زیر، BigCardText، هر عددی را بین 0 و 999,999,999 تبدیل می کند. برای استفاده از آن، به سادگی نقطه درج را در داخل عددی که می خواهید تبدیل کنید یا فقط در سمت راست عدد (اگر یک رقمی است) قرار دهید.
Sub BigCardText() Dim sDigits As String Dim sBigStuff As String sBigStuff = ""Select the full number in which the insertion point is located Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdMove Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtendStore the digits in a variable sDigits = Trim(Selection.Text) If Val(sDigits) > 999999 Then If Val(sDigits) <= 999999999 Then sBigStuff = Trim(Int(Str(Val(sDigits) / 1000000)))Create a field containing the big digits andthe cardtext format flag Selection.Fields.Add Range:=Selection.Range, _ Type:=wdFieldEmpty, Text:="= " + sBigStuff + " * CardText", _ PreserveFormatting:=TrueSelect the field and copy it Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend sBigStuff = Selection.Text & " million " sDigits = Right(sDigits, 6) End If End If If Val(sDigits)<div>When using the macro, make sure that the number you are converting does not contain extraneous information, such as dollar signs or commas. When you run BigCardText, the macro checks to see if the selected number is over one million. If it is, it first works on the portion above one million, converting it to words. Then, the value below one million is converted. The final, full wording is put together and pasted back into the document, ready for use.