ActiveX Automation example (Windows)
Private Sub Form_Load()

'----------------------------------------------
' Sample code for accessing FileMaker Pro
' in Visual Basic.
'
' "FileMaker Pro 7.0 Type Library" must be checked
' and available in Visual Basic's Project/References.
'----------------------------------------------
 
'----------------------------------------------
' Declaring Objects and Launching FileMaker
'----------------------------------------------
 
' Declare object variables
Dim FMApp As FMPro70Lib.Application
Dim FMDocs As FMPro70Lib.Documents
Dim FMActiveDoc As FMPro70Lib.Document
' Launch FileMaker
Set FMApp = CreateObject("FMPRO.Application")
 
' Set the documents object
Set FMDocs = FMApp.Documents
 
' Make FileMaker visible (when launching from automation,
' FileMaker remains hidden by default.)
FMApp.Visible = True
 
'----------------------------------------------
' Querying open documents
'----------------------------------------------
 
'Check the open document count
If FMDocs.Count = 0 Then
Debug.Print "No open documents"
Else
Debug.Print "Open document count is:"; FMDocs.Count
End If
 
'--------------------------------------------------
' Opening a FileMaker database and running a script
'--------------------------------------------------
 
' Note: A FileMaker file "c:\testing.fmp12" must be available
' with a script called "First Script" in order for the following
' to work.
Dim myOpenFile As Object ' note: can also be declared As
FMPro70Lib.Document
 
Set myOpenFile = FMDocs.Open("c:\testing.fmp12", "","")
myOpenFile.DoFMScript ("First Script")
 
'--------------------------------------------------
' Querying the active document
'--------------------------------------------------
 
Set FMActiveDoc = FMDocs.Active
 
' Display the active document's name
Debug.Print "The active file is "; FMActiveDoc.FullName
 
'--------------------------------------------------
' Enumerating and closing documents
'--------------------------------------------------
 
Dim TempToc As Object
 
If FMDocs.Count > 0 Then
 
For Each TempDoc In FMDocs
Debug.Print "About to close document: "; TempDoc.FullName
TempDoc.Close
Set TempDoc = Nothing
Next
End If
'----------------------------------------------
' Clean up and Quit
'----------------------------------------------
Set FMDocs = Nothing
Set FMActiveDoc = Nothing
Set myOpenFile = Nothing
 
' Quit FileMaker and release the variables
' (Note: always set the application variable to Nothing after quitting.)
FMApp.Quit
Set FMApp = Nothing
End Sub
Related topics 
Using FileMaker Pro ActiveX Automation (Windows)
ActiveX Automation objects, methods, and properties (Windows)