© Merry L. Morris
Introduction to writing simple macros
Writing OCLC Connexion Client Macros
OCLC Connexion Client Macro Mini-tutorial (Some of) My OCLC Connexion Client Mini-macros
Writing Microsoft Excel Macros
Excel macro mini-tutorial
Excel Macros Simplified
(Some of) My Excel Mini-macros

Yes, There is more you can do ...
but it is still simple!


---------------Mini-tutorial (continued)---------------



You can add variables to your macros to make them even more useful. All of the tutorials I have seen so far (including the section on writing macros on the OCLC Connexion Client website and in the OCLC Connexion Client Help files) show you how to create variables using syntax that can look unfamiliar and daunting if you are not an experienced macro programmer.

As you can probably guess, I use a simpler way that is far less intimidating to people who don't understand programming.

Look carefully at the macro below.

Sub Main
        dim CS as object
        set CS = CreateObject("Connex.Client")
        CS.AddField 1, "500 Various authors."
End Sub

This version of the macro resulted from recording the steps to add a 500 field at the beginning of the 500's and insert the note "Various authors." (without the quotation marks).

Now look at the second version of the macro. This version allows the user to vary the text in the note by typing whatever text he or she wants to insert into a simple input box.

Sub Main
        dim CS as object
        dim notetext as string
        notetext = inputbox("Note","","")
        set CS = CreateObject("Connex.Client")
        CS.AddField 1, "500 " & notetext
End Sub

Now look at the third version of the macro. This version allows the user to vary the text in the note by typing whatever text he or she wants to insert into a simple input box AND to vary the position of the inserted 500 field in relation to all the other 500 fields in the record.

Sub Main
        dim CS as object
        dim relativeposition as string
        relativeposition = inputbox("Relative position","","")
        dim notetext as string
        notetext = inputbox("Note","","")
        set CS = CreateObject("Connex.Client")
        CS.AddField relativeposition, "500 " & notetext
End Sub

This is the input box ...



... created by the second version of the macro (shown here as it appears in the macro editor.)


These are the input boxes ...




... created by the third version of the macro (shown here as it appears in the macro editor).


Now, wasn't THAT simple, too?!

Your homework assignment is:

Copy and paste all three versions of the macro into your OCLC Connexion Client macro editor. Click here if you don't remember how to copy and paste macros to test them.

Run the macros to see how they work.

Then record a new macro and use the method described in this mini-lesson to create your own simple variables!