sort out font for Cl and Al

In Arial the font for the 9th letter and the 12th letter of the alphabet are the same, which means that the symbol for chlorine is the same as for carbon monoidide. OCR exam papers solve this problem by writing the 12th letter of the alphabet in Book Antiqua Italic when it is in the formula for chlorine or aluminium. The following macro does that – it won’t change the letter in a word containing that letter, but will when it is in a formula.

'italic and book antiqua l for Cl and Al
Selection.WholeStory
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "([CA])(l)([!a-z])"
        .Replacement.Text = "\1++l++\3"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Italic = True
    With Selection.Find
        .Text = "++l++"
        .Replacement.Text = "l"
        .Replacement.Font.Name = "Book Antiqua"
        .Replacement.Font.Size = 11
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: