View Single Post
 
Old 01-08-2021, 01:04 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by WJSwanepoel View Post
Eg. A sentence that reads: Vergelyk Hand. vii. 12, en die ook by v. 1.

"Hand." will appear in my list but "by" will not. So it needs to convert to:

Vergelyk Hand. 7:12 en ook by v. 1.
As coded, that example won't be converted at all, since the numbering format is not as you described, which had a roman numeral, followed by a period, space single digit, period (which was to be deleted). The code looks for and processes only the specific sequence you described. Even allowing for multiple digits and no period, via:
Code:
.Text = "[A-Z][a-z]{1,3}. [iIvVxXlLmMcCdD]{1,}. [0-9]@>"
your second expression would not be processed, since it lacks the starting capital.

If there remains a risk of false matches, you could replace:
Code:
    .Text = Split(.Text, ".")(0) & ". " & _
        Roman2Num(Trim(Split(.Text, ".")(1))) & _
        ":" & Trim(Split(.Text, ".")(2))
with:
Code:
    If InStr("|Bob|Hope|", "|" & Split(.Text, ".")(0) & "|") > 0 Then
      .Text = Split(.Text, ".")(0) & ". " & _
        Roman2Num(Trim(Split(.Text, ".")(1))) & _
        ":" & Trim(Split(.Text, ".")(2))
    End If
where "|Bob|Hope|" is your set of valid abbreviations, each bounded by a | character.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote