FileMaker Pro Documents Object - File Maker

The Documents collection (the “Documents object”) consists of all databases that are currently open within the FileMaker application (thus the word “collection”). By sending commands to the Documents object, you can tell FileMaker to open and close databases. The Documents object supports six properties; three are pointers to objects, and three are read-only properties. The Documents object supports two methods.

The first three properties are pointers and refer to the Application object:

This is a pointer to the Documents’ root Application object.

This is a pointer to the Documents’ Application object.

This is a pointer to the currently active FileMaker Pro database (Document).

The next three properties are read-only properties and they are:

This is the number of databases (Documents) currently being run by the FileMaker Pro Application object. It represents the total number in the Documents collection.

Use this property to implicitly refer to the object in a For Loop. It returns an Enumerator object, allowing you to navigate all the databases in the Documents collection.

This allows you to reference a specific database (Document) that is currently running (in the Documents collection) in FileMaker Pro. You can use this to stipulate a specific database by:

  • Using a string that identifies the database by file name (must include the full file path to the database).
  • An index number to identify the database in the collection you want to reference (must be a long integer).
  • NULL, which will return the entire collection of databases.


Open(name, password)
This method opens a FileMaker Pro database (full file name including path) using the password you specified (bothvariables mustbe strings).It opens the database (Document) and returns a pointer to the Document object.

This will immediately close all open FileMaker Pro databases (all Documents in the Documents collection) without any warning to users who may be connected.

This illustration shows the Documents object and its properties and methods:

Documents object and its properties and methods

FileMaker Pro Document Object
Not to be mistaken for the Documents object, the Document object (without the “s”) refers to just one of the currently open FileMaker databases. It allows you to do the most useful thing you can with ActiveX automation in FileMaker Pro, which is the ability to call a script in a database’s ScriptMaker. The Document object supports six properties, two of which are pointers to the Application and Documents objects, and four of which are read-only properties.

The Document object also supports four methods.

The first two properties are pointers and refer to the Application object:

This is a pointer to the root Application object.

This is a pointer to the Documents object, which is the parent to the Document (database). The next four properties are read-only properties:

This returns the full file name (including the path) of the currently active database. If this database is being remotely hosted, then it will not include the path in the file name.

This returns the file path of the currently active database, but it does not include the file name or its extension.

txtFMPDocument1Path = FMPDocument1.Path

This returns TRUE if the current active database has been saved.

txtDocsSaved.Text = FMPActiveDocument.Saved

This returns TRUE if the current database’s window is the active one on the desktop or FALSE if it isn’t.

If FMPDocument1.Active = False Then comDocsOpen1_Click


This will make the current database’s window the foremost, active window in FileMaker’s application window.


This forces FileMaker Pro to save the currently active database and flush the cache to disk.


This closes the currently active database and removes it from the Documents collection.


The most useful Document object method that allows you to specify which script (as a string variable, please) in the active database that you would like to run. This script must already exist in the database for it to be run, obviously. FMP Active Document.DoFMScript ("Go to form layout") This illustration shows the Document object and its properties and methods:


Example #2: FileMaker Pro’s Application Objects . . . All Together Now!
Following is a more complex example of the various FileMaker Pro objects in action. This example uses all three objects: the Application, Documents, and Document objects. It is also written in a more conventional format, the type that would be used when building an actual external application using VB. That is to say that specific events are fired as subroutines and code is re-used wherever possible by one subroutine calling another to do something. (You may find it easier to explore the code for this solution in VB instead of here on the printed page.) This example was also written using VB, which must be installed first before the example can be run.

Document Object FullName Path Saved Application Parent Activate() Active DoFMScript (Scriptname) Save() Pointer Properties Close() Read-Only Properties Method
  1. Locate the Object_Demo_Setup_Files folder and launch the Setup.exe file. This will install the application on your Windows machine.
  2. Next, launch the Object_Demo.exe file that was installed. Alternatively, if you have VB, you can open the project Object_Demo .vbp and run the example manually.
  3. When you have launched Object_Demo.exe, you should see a form (a view, much like a FileMaker layout) on your screen that looks like this:
  4. file-maker-pro-ob

  5. Locate the path to the demo Business Cards.fp5 and Business Cards2.fp5 databases by using the Set Path button.
  6. Click the Connect button, which will launch FileMaker Pro and open these two databases. You can then close a database, open a database, run a script, and view the results of your actions using this VB application. Press the Quit button to exit the demo at any time.

Here is the code for this VB project including helpful commentary sprinkled here and there:

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

File Maker Topics