Using FileMaker Pro ActiveX Automation (Windows)
The FileMaker Pro Type Library
The type library describes the objects, properties, and methods exposed by FileMaker Pro, so that other ActiveX clients can access FileMaker Pro.
The FileMaker Pro Type Library is included in the FileMaker Pro executable. It is not a separate file. The FileMaker Pro Type Library was registered on your computer when you installed FileMaker Pro.
In Visual Basic, add "FileMaker Pro Type Library" to the list of Available References in your project.
Important  You must add the FileMaker Pro Type Library to the list of available type libraries in the application you will be using to implement your ActiveX Automation document. If you don't add the type library, you won't be able to address FileMaker Pro via ActiveX Automation.
The method for adding this library varies in the different ActiveX Automation authoring tools. Consult the manual that came with your ActiveX Automation authoring tool if you are unsure of how to do this. The following procedure explains how to do this in Microsoft Visual Basic.
To add the FileMaker Pro Type Library to Microsoft Visual Basic:
1.
In Microsoft Visual Basic, choose Project menu > References > Add Type Library.
2.
Enable the checkbox to the left of the FileMaker Pro Type Library.
3.
FMPro70Lib appears in the Visual Basic Object Browser once the project references include the FileMaker Pro Type Library. All of the objects, methods and properties that FileMaker Pro exposes for Automation control are now available.
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
Reference counts and releasing an object
When an automation object is referenced, a reference count increments to let FileMaker know that a process is using that object. In Visual Basic, an object is reference counted every time you set the declared variable to a FileMaker object, for example:
' just a declaration - no references yet
Dim FMDocs as FMPro70Lib.Documents
' this line causes a reference of FileMaker's "Documents" object
Set FMDocs = FMApp.Documents
' this causes a second reference of the same FileMaker "Documents" object
Set FMDocs2 = FMApp.Documents
FileMaker may not exit until all reference counts are released. In Visual Basic, you can release the reference count by setting the object variable to "Nothing", for example:
' releases the reference to the FileMaker "Documents" object
Set FMDocs = Nothing
' releases the 2nd reference to the FileMaker "Documents" object
Set FMDocs2 = Nothing
' releases the reference to the FileMaker Application object
Set FMApp = Nothing
It is good practice to always set object variables to "Nothing" when you have finished using the variables.
Access Privileges
FileMaker Pro uses the Documents.Open(filename As String, accountName As String, password As String) method. If the accountName and password arguments are empty strings, the file will be opened as a client user.
Scripts
FileMaker Pro scripts called directly by Automation may interrupt each other.
FileMaker Pro scripts called from within other FileMaker Pro scripts will run in order, as expected.
Remotely hosted files
It is not possible to open a hosted file using ActiveX Automation alone. To open a hosted file using Automation, you can either open the hosted file directly using the FileMaker Open dialog box, and then access the file using Automation, or you can write a FileMaker Pro script that opens the hosted file, and then call that script via Automation.
Related topics 
Using FileMaker Pro ActiveX Automation (Windows)
ActiveX Automation example (Windows)