This information is for Version 2.0 of Cardbox for Windows.
We recommend that you upgrade to Cardbox 3.

(logo)

Using macros to link to external objects

 


(Technical support)

With the latest versions of Cardbox, you can put the name of an external object in a field, and then very simply launch that object from within Cardbox.  Here are some examples:

Store Use a keystroke or pushbutton to
The name of a document Open the document for editing.
The name of a sound or video clip Play it.
The address of a Web page Open it
An email address Start writing an email

This article is a tutorial on how to do all this.  After you have been through it once and understood the concepts, you will find that the process of setting up links to external objects from Cardbox is quite simple.

Object Linking and Embedding (OLE)

Cardbox supports Microsoft's OLE standard, and you can use it to embed objects into your Cardbox database, using a special Object field, or to keep the objects themselves outside Cardbox but embed links to them.

OLE is complex and cumbersome, and not always as reliable as it might be.  You can read all about it in the Cardbox manuals and the on-line help, but unless you are quite expert, and have a good reason for preferring OLE, we recommend that you use the "lightweight" methods described here instead.

 

 

Exercise 1: the Run command

The system menu is at the top left-hand corner of the Cardbox window.  You can open it by clicking on it or by pressing Alt+Space.

Hidden away inside Cardbox's system menu is a command called Run.  Like the Run command in the Windows start menu, it does a lot more than just run programs.

It can open documents.

Select the Run command and type the name of a document file.  You will have to type the whole filename - for example, "c:\My Documents\letter.doc" rather than just letter.doc.  The quotation marks are necessary if the filename that you are entering contains spaces.

It can view pictures and play sounds or video clips.

You do this in exactly the same way: only the filenames will be different.

It can open Web pages.

Some versions of Windows won't let you use http: or mailto: prefixes from within Cardbox.  If this happens to you, see If mailto: or http:// Links Don't Work.

You'll need to be on-line for this.  Select the Run command and type the address of a Web page, such as http://www.cardbox.com.  Your Web browser will start up and open the page.

It can help in writing emails.

You don't need to be on-line for this.  Select the Run command and type an email address preceded by "mailto:", such as mailto:sales@cardbox.com.  Your email program will bring up a blank email with the destination address already filled in.

Exercise 2: getting the name from a Cardbox field

Don't worry if this exercise sounds like a slow and complicated way of doing a simple thing.  In the next exercise it'll all be automated.

In practice you won't want to type the name of your chosen document or Web page every time.  If you haven't already done so, create a field in your Cardbox database so that you have somewhere to put the name of an object.  For the purpose of this tutorial, we'll assume that you've done this, and that you've called the field THING.

Create a record that has a filename (or Web page name) in the THING field.  For the moment, make this a full filename or page name, with all the drive letters, path names, and prefixes that you need.

Now try this:

  1. Highlight the name that you've stored in the THING field.
  2. Press Ctrl+C to copy the name to the Clipboard.
  3. Select the Run command.
  4. Press Ctrl+V to paste the name into the space in the dialog box.
  5. Press OK.

This should work just like the first exercise, except that you haven't had to type the filename by hand.

Some extra automation

You'll have to make some strategic decisions about how the names in the THING field relate to the actual commands that need to be entered.

For example, if all the documents that you will refer to are Word documents and stored in the My Documents folder, then you may want to put just the name of each document in the field, and fill in the rest as part of the Run command (remember, this is going to be automated).  Thus the command that you give to Run could look like this:

"c:\My Documents\letter.doc"

where only the underlined red text comes from the field.  To do this:

  1. Type the first part, "c:\My Documents\.
  2. Press Ctrl+V to paste in letter from the Clipboard.
  3. Type the second part, .doc".

Of course, the more you automate like this, the less flexibility you'll have (if you fill in all the details automatically as in this example, you won't be able to use the same field for documents and for Web page addresses).  You'll have to decide; but remember, if you can get it wrong, Cardbox's Batch Edit feature makes it easy to change the contents of a field throughout the database.

Exercise 3: automating the process

If you've worked through this tutorial so far, you'll have got a way of opening objects that is two or three times more cumbersome than reading the relevant field and typing a command by hand into Windows.  But everything that you've done so far can be recorded as a single macro, which is quick and easy to call up.

As before, we'll assume that you have a field called THING, which contains a complete filename with drive, path, and filename (and quotes if necessary), or a complete Web page name with the http:// prefix.

If you don't know about macros, it will really help you if you read the manual or the on-line help, so that you understand the basic concepts.

  1. Select the Cardbox command Macros, Start Recording, or press the Record button on the toolbar.
  2. A small toolbar will appear on top of the Cardbox window. Press the button marked "Fields".  A list of fields will appear.
  3. In the list of fields, select the THING field.  You'll see the contents of the field in the current record, as a confirmation.
  4. When you're sure that you've chosen the right field, press the button marked "Copy".  This will copy the contents of the field to the Clipboard.
  5. Select the Run command.
  6. Press Ctrl+V to paste the name into the space in the dialog box.
  7. Press OK.  The document or Web page should open.
  8. Switch back to Cardbox.  Press the Stop button on the toolbar, or select the Cardbox command Macros, Stop Recording.
  9. A dialog box will pop up that lets you give the macro a name.  If you need help on the use of this dialog box, press the F1 key.

Playing the macro

To prove that something useful has happened, select the Cardbox command Macro, Play and pick the macro that you have just saved.  You should see the document opening just as before.

For further proof, change the contents of the THING field, or move to a record where the THING field has different contents, and play the macro again.  You should see a different document opening.

The document that you open in this part of the exercise must really exist, because if it doesn't, the Run command will report an error and the macro manager won't record the steps you took to perform that command.

What next?

First of all, you can go back to the sidebar of Exercise 2 and decide what parts of the command should come from the THING field and what parts should be fixed as part of the macro.  Once you have made that decision, you can re-record the macro, or, if you feel confident, use the Macro Manager to edit it directly.

Having to use the Macro, Play command isn't very automatic.  You can automate the process still further, so that the macro is played (and the document opened)

  • By a single keystroke.
  • Or by pressing a button next to the field.

For the full story on how to do this, see Run macros fast: menus, keystrokes, and pushbuttons.

 

2003 Cardbox Software Limited  (logo)