Skip to main content
OCLC Support

ReplaceTextAll

Find the syntax, use, parameters, return values, and an example for the ReplaceTextAll macro command in Connexion client.
Syntax CS.ReplaceTextAll (sOldText, sNewText, bMatchCase)
Use to Replace all occurrences of “found” text with specified text.
Parameters
  • For sOldText, enter the text you want to find, enclosed in quotation marks (“).
  • For sNewText, enter the text you want to replace the “found” text, enclosed in quotation marks (“).
  • For bMatchCase, enter the boolean value to specify whether to match upper- and lowercase exactly or not match case:
    • True - Match upper- and lowercase exactly
    • False - Do not match case
Comments ReplaceTextAll replaces text only within a single cell of a field, not across cells. You can replace all specified tags or indicators or data separately, but not in combination.
Return values An integer representing the number of replacements.
Example Sub Main()

     Dim CS As Object
     Set CS = GetObject(,“Connex.Client”)

     Dim sText As String
     Dim nNumReplaced As Integer

     If CS.IsOnline = False Then
          CS.Logon ““, ““, ““
     End If

     CS.Search “WC”, “#1”

     CS.CursorRow = 1
     CS.CursorColumn = 1

     If CS.FindText(“XXX”, False) = False Then
          MsgBox “XXX - not found
     End If

     If CS.ReplaceTextAll(“Rand”, “XXX”, False) > 0 Then
          MsgBox “All instances of Rand were replaced with XXX”
     End If

     nNumReplaced = CS.ReplaceTextAll(“xxx”, “YYY”, True)

     If nNumReplaced > 0 Then
          MsgBox “Incorrect xxx - replaced”
     Else
          MsgBox “Correct xxx - not replaced”
     End If
End Sub

What this example does
  • Logs on to Connexion if not already logged on, using the default authorization and password you selected in Tools > Options > Authorizations tab.
  • Searches WorldCat for record number 1.
  • Places the cursor in the first column of the first row (beginning of the record).
  • Searches the record for the text XXX, disregarding upper- and lowercase (case- insensitive), and returns the message: XXX - not found if the text is notfound.
  • Searches for the text Rand, disregarding upper- and lowercase (case-insensitive). If it is found, replaces all instances of Rand with the text XXX, and returns the message: All instances of Rand were replaced with XXX. Also returns an integer representing the number of replacements.
  • Finds and replaces all instances of the text xxx with the text YYY, matching case exactly. If the action is successful (lowercase xxx is replaced), returns the message Incorrect xxx - replaced. If the xxx text found does not match case exactly, returns the message: Correct xxx - not replaced. Also returns an integer representing the number of replacements.