Skip to main content
OCLC Support

Create Connexion client macros

Find out how to write macros and check macro syntax in Connexion client.

Overview

There are two ways to create macros for the client. You can:

  • Write your own macros in the macro editor, or copy and paste from an existing macro to a new one and then edit the new macro as needed.
    Or
  • Record macros automatically using the macro recorder: You start the recorder, do a series of actions in a procedure you want to automate (using the mouse or the keyboard), and the recorder writes a macro that captures the procedure. See Record macros (create automatically) for more information.

 Note: See a list of client commands that are not available for use in macros you write or record. The following commands are available for use in macros you write but cannot be recorded: View the next or previous 100 records from a list (View > Previous 100 Records or Next 100 Records).

Write macros

  1. Navigate to Tools > Macros > Manage or press <Ctrl><Alt><Shift><G>. The Macro window opens.
  2. Under the Macros list, select the macro book in which you want to create the new macro. You must use macro books to contain macros.
    Or
    Create a new macro book in which to store the new macro:
    1. In the Macro window box, click New Book.
    2. Enter a descriptive name over the highlighted default name New Book.
    3. Press <Enter>.
  3. Click New Macro.
  4. In the Macro Description window, enter a unique description of the macro's purpose and then click OK or press <Enter>.
  5. In the text box with NewMacro highlighted, enter an appropriate name for the new macro and then press <Enter>.
  6. Click Edit.

    The OCLC Connexion Macro Editor and Debugger opens. Its title bar gives the names of the macro book and macro. In the work area, the start and end text of a macro are provided:

    MacroName:[name you typed]
    'MacroDescription:[description you typed]

    Sub Main()

    End Sub
     
  7. Between Sub Main and End Sub, enter commands and appropriate comments to create the macro.
    • To create a specific instance of the client object class, macros that use client commands must begin with the lines:
           Dim CS as Object
           Set CS = GetObject(,“Connex.Client”)
    • In macros that use variables (numbers, strings), include lines to declare the data type of each variable to be used in the macro.
           Example:
           The first part of a macro using the GetField command declares the variable sData as a string to store the text of the specified field:
           Dim CS as Object
           Dim sData as String

           Set CS = GetObject(,“Connex.Client”)
  8. Press <Enter> at the end of each line. Make sure End Sub remains as the last line of the macro.
  9. On the Macro Editor toolbar, click Check (Check button) to check macro syntax. See Check macro syntax for more information.
  10. Click Save (Macro Save button).
  11. When finished editing, click File > Exit or press <Ctrl><F4>.

Macro example

Sub Main()

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

If CS.Logon(““, ““, ““) = True Then

MsgBox “Logon successful”

End If

CS.Search “WC”, “#1”

CS.AddFieldLine “300Line    10 test”, 10
If CS.AddField(2, “500    Another test”) = True Then

MsgBox “500 field successfully added”

End If

End Sub

This example:

  • Logs on to Connexion if not already logged on, using the default authorization and password you selected in Tools > Options > Authorizations tab (leaves logon values blank).
  • Searches WorldCat for record number 1.
  • Adds a new field 300 in the tenth line of the record (inserted as the tenth variable field) with no indicators (two spaces between the tag number 300 and the text of the field). Adds the text Line 10 test to the field. (No confirmation message.)
  • Adds a second instance of repeatable field 500 (that is, adds a new field 500 below the first existing field 500) with no indicators and the text Another test. If the action is successful, returns the confirmation message: 500 field successfully added.

See List of Connexion client macro commands for detailed descriptions and examples for each command in sections organized by function.

Convert an existing macro to 3.X macro format

When you download a new macro to Connexion client version 3.0 or newer, which was written with Connexion client versions 2.63 and prior, you will need to convert the .mbk file to 3.0 format in order to run it.

  1. Navigate to Tools > Macros > Convert to 3.0 Macro Format. The Convert to 3.0 macro format window opens.
  2. Select which macro book(s) you want to convert. Macro books that have been converted will be selected in the Converted column.
  3. Click Select MacroBook. The default macro book location opens (\Users\<user>\AppData\Roaming\OCLC\Connex\Macros (where X is the letter of your hard drive)).
  4. Select the .mbk file you want to convert from your computer and click Open to return to the Convert to 3.0 macro format window. The file you selected will appear after Selected Macro.
  5. Click Convert. An OCLC Connexion dialog opens with the full name of the .mbk file that was converted and the number of macros in the .mbk file that:
    • Were converted
    • Were already converted - Macros that are already converted are skipped.
    • Failed to convert or compile - Macros that fail to convert and/or compile must be edited manually.
  6. Click OK to close the OCLC Connexion dialog.
  7. (Optional) Repeat steps 2-6 for additional .mbk files.
  8. Click Close to close the Convert to 3.0 macro format window.

Check macro syntax

When you create or edit a macro, you must check the macro syntax (click Check (Check button) on the toolbar). The Macro Editor displays a message on the status bar of the Editor window.

  • If the macro contains no syntax errors, the message is: Successfully compiled [macrobook]![macroname].sbl
  • If the macro contains syntax errors, the message is: _Error(s) in [macrobook]![macroname].sbl. Lines containing syntax errors are highlighted in red.

Review errors

Click the Next Error button (Next Error button) and Previous Error button (Previous Error button) on the Macro Editor toolbar to move between error lines in the macro.

View details of syntax errors

  1. Click the Console button (connexion-client-macro-console-button.png) on the Macro Editor toolbar. A new window opens at the bottom of the Editor window, just above the gray message bar. The window displays output from the syntax checker.
  2. Drag the separator up to expand the console window. Maximize the Editor window to provide more space if needed.
  3. Click the Check button (Check button) on the Macro Editor toolbar. In the console window, the Editor displays messages that give the line number containing each syntax error (in parentheses following the macro name) and identify the general type of error.