Jump to content
Salesforce and other SMB Solutions are coming soon. ×

ActiveX in FM7


Recommended Posts

to specify in more details here's my doubts:


I don't know anything about VB and have to adapt a script to use it with Filemaker 7... following details found of different sources and adapting what I had from version 6 I get the following in VB:


Dim FMDocs As FMPRO70Lib.Documents

Dim FMDoc As FMPRO70Lib.Document

Dim FMApp As FMPRO70Lib.Application


Set FMApp = CreateObject("FMPRO70Lib.Application")

Set FMDocs = FMApp.Documents

Set FMDoc = FMDoc.Open("C:\AcredSys\foto.fp7", "", "")


Somehow I get an error at the line of CreateObject. I have tried with

Set FMApp = CreateObject("FMPRO.Application") but it won't work either.

Link to comment
Share on other sites

Hello Henk,


I am not sure what it is you want Filemaker to do from VB.

Below please find some code I came up with for testing script process speed.

It originally uses code from within a Word document (Macro) but it can also be easily converted to a full .exe program in VB.




'Purpose of program:

'Benchmarking of Filemaker scripts

'Timing in Filemaker is too crude as the minimal

'time measurement is 1 second

'Fractions of a second can not be displayed in filemaker.




'Make a reference to the Filemaker Pro 7.0 Type library before writing any

'further code or running this project



'For Filemaker 5.0 /5.5 or 6.0 use the references to those Type Libraries

'Rename all objects from FMPRO70LIB.xxxxxx to FMPRO50LIB.xxxxxx




Dim FMApp As FMPRO70Lib.Application

Dim FMDBs As FMPRO70Lib.Documents

Dim FMActiveDoc As FMPRO70Lib.Document


'Note: A command button named "cmdOpenDB" is needed on the form or Word document


Private Sub cmdOpenDB_Click()


End Sub


'Note: A command button named "cmdClearTimelist" is needed on the form or Word document


Private Sub CmdClearTimelist_Click()


End Sub


'Note: A command button named "cmdRunscript" is needed on the form or Word document


Private Sub cmdRunscript_Click()


End Sub



Private Sub Run_script()

'Run a script in Filemaker, called from within the VB program (or Word/Excel document)

Dim Start As Double

Dim Finish As Double

Dim Status As Integer

lblScriptStatus = "Script not active"


Set FMApp = CreateObject("FMPRO.Application")

' Set the documents object with the correct path and filename.

Set FMDBs = FMApp.Documents


'Listbox named lstOpenDbs must be present on the form or document

If lstOpenDbs.Text "" Then

'Open the Filemaker file with username Admin and in this case empty password.

Set FMActiveDoc = FMDBs.Open(lstOpenDbs.Text, "Admin", "")

MsgBox ("Now activated: " & FMActiveDoc.FullName), , "Message"


'Start running the script

Start = Timer

'Textbox named txtScriptname must be present on the form or document

FMActiveDoc.DoFMScript (txtScriptname.Text)

lblScriptStatus = "Script active"

Status = FMApp.ScriptStatus

While FMApp.ScriptStatus 0



Finish = Timer

'If a typo is made in the scriptname no script will be executed

'but no error message comes back from filemaker either


'Label named lblScriptstatus must be present on the form or document

If Status = 0 Then lblScriptStatus = "Script not executed"


If Status = 1 Then lblScriptStatus = "Error within script"

If Status = 2 Then

lblScriptStatus = "Script executed"

'Add the scriptname and the resulted time to the result list

lstTimeResult.AddItem txtScriptname.Text & ": " & Round((Finish - Start), 3)

End If

End If


'Clean up, destroy all created objects

Set FMDBs = Nothing

Set FMActiveDoc = Nothing

Set FMApp = Nothing


End Sub



'Find all the databases which are currently open

'Display all the filenames in a listbox (clickable for further use)

'This makes other code more flexible as filenames are not hardcoded


Private Sub FindOpenDBs()

Set FMApp = CreateObject("FMPRO.Application")

Set FMDBs = FMApp.Documents

Dim Tempdb As FMPRO70Lib.Document

Dim Opendbs As String

Dim OpenDocs As String

On Error GoTo ErrorHandler



If FMDBs.Count > 0 Then

For Each Tempdb In FMDBs

Opendbs = Tempdb.FullName

lstOpenDbs.AddItem Opendbs

Set Tempdb = Nothing


End If

Set FMApp = Nothing

Exit Sub


MsgBox "Filemaker has no files open"

End Sub



Private Sub Document_Open()

'On opening the Word document, the lists with previous results are wiped clean



End Sub


Private Sub ListOpenDbs_Click()



End Sub






Link to comment
Share on other sites

I see that there is some interest in this code. I have tinkered with it some more and uploaded it to our website.

You can download a zip copy of the actual Word 2000 document from:



By the way I found a nice quirk in FM: the active X calling of a script only works if you have the script flagged as "show in menu" in scriptmaker.



Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

Terms of Use