'MacroName:Lexile
'MacroDescription:Lexile

option explicit

Sub Main

   Dim CS As Object
   Set CS = CreateObject("Connex.Client")
   
   dim x%
   dim tag521$, Lexile$
   dim found521

   x% = 1
   found521 = CS.GetField ("521", x%, tag521$)
   do 
      if mid(tag521$, 6, 9) like "Lexile: #" then
         Lexile$ = mid(tag521$, 14)
         if right(Lexile$, 1) = "." then Lexile$ = left(Lexile$, len(Lexile$) - 1)
         tag521$ = left(tag521$, 5) & Lexile$ & " " & chr(223) & "b Lexile."
         CS.DeleteField "521", x%
         CS.AddField x%, tag521$
      end if
      x% = x% + 1
      found521 = CS.GetField ("521", x%, tag521$)
   loop until not found521
   
End Sub