Help

Table Of Contents
Creating scripts to automate tasks
F
ILEMAKER PRO HELP 431
Declaring FileMaker Pro as the Application object
Declare the FileMaker Pro as the Application object each time you create an ActiveX Automation
script or application to control FileMaker
Pro. This can be done with a single line of code at the top of
your Automation document, where it appears with your other definitions.
For example:
Dim FMProApp As FMPro70Lib.Application
Getting an Application object
To make any Automation calls to FileMaker, you must first get access to the FileMaker Application
Object. There are two ways to do so: by calling CreateObject, or by calling GetObject.
To use either call, first declare the Application object:
Dim FMProApp as FMPro70Lib.Application
For CreateObject only:
Set FMProApp = CreateObject("FMPRO.Application")
CreateObject will launch FileMaker if it is not already running.
The GetObject function retrieves an Application object only if FileMaker is already running.
For GetObject only:
Set FMProApp = GetObject(, "FMPRO.Application")
Notice the comma, which indicates that the first argument to GetObject — a path to a disk file — has
been omitted. The comma is required because under some circumstances GetObject takes a
filename as its first argument. To retrieve an instance of FileMaker, however, you must omit the
filename argument, or an error will occur.
Calling a FileMaker Pro script
To run a FileMaker Pro script via ActiveX Automation, call the DoFMScript function with the name of
the script as the variable.
For example:
Dim FMProApp as FMPro70Lib.Application
CreateObject("FMPRO.application")
Dim FMProDocs, FMProDocs.Open("c:\MyFile.fmp12","","")
Dim FMProDoc
FMProDoc.DoFMScript ("MyScript")
Set FMProDoc = nothing
Toggling the visibility of the FileMaker Pro application
When FileMaker Pro is launched by Automation, it will run hidden by default. You can use the visible
property to hide or show FileMaker
Pro.
For example, to hide the application:
FMProApp.Visible = False
To show the application:
FMProApp.Visible = True