Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Changing Roman Numerals to Arabic.

Changing Roman Numerals to Arabic

Written by Allen Wyatt (last updated March 16, 2019)
This tip applies to Word 97, 2000, 2002, and 2003


1

Bradley has a document that has, within text, many Roman numerals. He needs an easy way to change these thousands of Roman numerals to Arabic. These are not fields of any nature; they are simply typed in text as Roman numerals. He wonders if there is a way to easily change them to their Arabic equivalents.

Unfortunately, there is no function in Word that will convert Roman numerals to Arabic. You could, if you want, simply use Find and Replace to search for Roman numerals, but you would have to do an individual search for each one. You could use a wild card search to search for a word that consists entirely of uppercase Roman numerals, which would make searching quite a bit easier. All you need to do is search for "<[CDILMVX]{1,}>" (without the quote marks) and make sure you have the Use Wild Cards check box selected. When you click Find Next, the next Roman numeral is located, and you can then manually change it to its Arabic equivalent.

Another way to try to do the conversion is with a macro. You could create a macro that looks at each word in your document and tries to determine if it is a candidate for consisting of Roman numerals. You may get some false positives, though, particularly if your document contains acronyms that could be confused as Roman numerals. (For example, if you use the acronym CC for credit card, that could be considered the Roman numeral for 200.)

The following set of macros will step through each of the words in a document and if the word contains only Roman numerals (I, V, X, L, C, D, and M) then the user is asked if the macro should convert the numerals.

Sub ConvertRoman()
    Dim wrdX
    Dim wrd As String
    Dim tstSW As Boolean
    Dim J As Long

    For Each wrdX In ActiveDocument.Words
        wrd = UCase(Trim(wrdX))
        If wrd = "" Or wrd = "I" Or wrd = vbCr Then
            tstSW = False
        Else
            tstSW = True
        End If
        For J = 1 To Len(wrd)
            If InStr("MDCLXVI",Mid(wrd, J, 1)) = 0 Then
                tstSW = False
                Exit For
            End If
        Next J

        If tstSW Then
            wrdX.Select
            Selection.MoveLeft unit:=wdCharacter, _
              Count:=Len(wrdX) - Len(wrd), _
              Extend:=wdExtend
            J = MsgBox("Convert " & wrd & " to Arabic", vbYesNoCancel)
            If J = vbCancel Then Exit Sub
            If J = vbYes Then Selection.TypeText Text:=RomanToArabic(wrd)
        End If
    Next wrdX
End Sub
Function RomanToArabic(Rm As String) As String
    Dim J As Long
    Dim ab As Long
    Dim cc As Long
    Dim dd As Long

    ab = 0
    Rm = Trim(Rm)
    J = 1
    Do
        cc = GetValue(Mid(Rm, J, 1))
        dd = GetValue(Mid(Rm, J + 1, 1))
        If cc < dd Then
            ab = ab + dd - cc
            J = J + 1
        Else
            ab = ab + cc
        End If
        J = J + 1
    Loop Until J >= Len(Rm)
    If J = Len(Rm) Then
        ab = ab + GetValue(Mid(Rm, J, 1))
    End If
    RomanToArabic = Trim(Str(ab))
End Function
Function GetValue(ss As String) As Long
    Dim Cde()
    Dim Cvalue()
    Dim J As Long

    Cde = Array("M", "D", "C", "L", "X", "V", "I")
    Cvalue = Array(1000, 500, 100, 50, 10, 5, 1)

    For J = 0 To 6
        If ss = Cde(J) Then
            GetValue = Cvalue(J)
            Exit Function
        End If
    Next J
    GetValue = 999999
End Function

Since an uppercase I is a very common word in text, the macros won't stop on each of them to determine if a conversion should be done. However, if the capital I is part of a longer word that consists of only Roman numerals (such as XLVII), then it is considered a candidate for conversion. The macros also assume that all your Roman numerals are uppercase.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12509) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Changing Roman Numerals to Arabic.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Dealing with Oily Skin

Does your skin feel greasy to the touch and are you having problems getting just the right look with your facial makeup? ...

Discover More

Allowing for Words that Contain Numbers

When Excel does a spell-check of the information in a worksheet, you may want it to ignore words that contain numbers. ...

Discover More

Copying Found Items to a New Document

Word allows you to use its searching capabilities to easily find multiple items in a document. What if you want to copy ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (menu)

Controlling the Bold Text Attribute

When processing a document in a macro, you may need to make some of your text bold. It's easy to do using the Bold ...

Discover More

Aligning a Paragraph in a Macro

If you are applying formatting from within a macro, you may want to change the alignment of various paragraphs. Here's ...

Discover More

Finding Long Sentences

For certain types of writing, you may want to make sure that the sentences in your document do not exceed a certain ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2021-04-07 11:50:33

Maya

Is there a similar way to convert Hindi numbers or digits to Western Arabic?


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.