Home

Macros and Programming

 

CardboxForumsMacros and Programming > "Using Cardbox from outside Cardbox"

Using Cardbox from outside Cardbox

Here is an example of a script accessible from Windows that opens Cardbox, performs some commands, and closes it again, all without any user intervention.

Current user: [none]
Register / Log In · Help

Posted By Post

cardboss

26-Apr-2005 08:07

To write a script that Windows will execute if you double-click on it, you create a file of type .VBS and put VBScript commands into it. This process is described on page 92 of the Macros and Programming book.

Here is an example that opens a database and prints all the records to the "Adobe PDF" printer. This isn't a very useful action on its own, but you can easily modify it to do something more meaningful.

  Const cbxPrintMainRecord = 1
  Set cbx=CreateObject("Cardbox.Application")
  Set win=cbx.Windows.OpenFile("C:\My Documents\MJK.FIL")
  win.Print cbxPrintMainRecord,,,,"Adobe PDF"

1. The 'const' line is necessary because the Windows Scripting Host doesn't know about Cardbox constants. Help Point 762 takes you to a list of constants.
2. This creates a "Cardbox Application" object from which you can navigate through the Cardbox object hierarchy. The object represents a newly started copy of Cardbox, which is invisible because you haven't told it to show itself.
3. This tells Cardbox to open a database, and stores a reference to the database window in the 'win' variable.
4. This sends the Print command to the window opened in step 3.
5. At the end, the new copy of Cardbox will close itself. This is because it isn't visible and the script that created it is ending.

If you want to write a script where Cardbox doesn't close itself at the end, just add a line like

  cbx.Visible=True

to make Cardbox visible before the script ends.

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home