New Xojo developer, but an advanced user of FileMaker. Trying communicate from Xojo to FileMaker using ActiveX.
The code example in ActiveX was created for Visual Basic:
Dim FMProApp As FMPro70Lib.Application
Set FMProApp = CreateObject(“FMPRO.Application”)
Set FMProApp = GetObject(, “FMPRO.Application”)
Dim FMProDocs, FMProDocs.Open(“c:\MyFile.fmp12”,"","")
FMProDoc.DoFMScript (“MyScript”)
Set FMProDoc = nothing
The compiler gives me errors on the first "Set FMProApp = CreateObject(“FMPRO.Application”)
How can I find information about converting this code to Xojo?
Hi Nelson! It’s great to see fellow developers from the FileMaker world here.
I don’t know how to help you with ActiveX, but you could do something very similar with FileMaker XML web publishing if your file is hosted on FileMaker Server.
Calling the following URL will cause a FileMaker Script to run on the FileMaker Server where the field data on the RETURNLAYOUTNAME layout will be returned.
One way is to manually create an OLEObject. Another way is to create an ActiveX using the menu option. I’m not really FM ActiveX/OLE to know which would be the better choice for your situation.
Even though calling a URL or using ODBC sound like excellent approach to manage FileMaker using Xojo, in the case of using ActiveX, you can call scripts with or without FileMaker Server. Actually the projected application requires for FileMaker Pro to be installed on the computer. If there is anyone that can provide light on using FileMaker ActiveX with Xojo, will be greatly appreciated. Thanks…
You can create a VB Script to run scripts. It may or may not be an option for you.
Example:
Option Explicit
Dim fmApp, fmDocs, fmDoc, SH
Dim theFile, theScript
theFile = "NameOfFileMakerDB"
theScript = "NameOfScript"
Set fmApp = CreateObject("FMPro.Application")
fmApp.Visible = True
Set SH = CreateObject("wscript.shell")
SH.AppActivate FMapp.Caption, True
Set fmDocs = fmApp.Documents
For Each fmDoc In fmDocs
If InStr(LCase(fmDoc.fullname), LCase(thefile)) > 0 Then
fmDoc.DoFMScript(thescript)
End If
Next
Set SH = Nothing
Set fmDoc = Nothing
Set fmDocs = Nothing
Set fmApp = Nothing
You create the script as a text file and use Folderitem.Launch to run it within your Xojo app. FileMaker must be running and the “database document” loaded.
Example:
Dim f as folderitem = SpecialFolder.ApplicationData.Child(“VBS”).Child(“myScriptName”)
if f <> nil and f.exists then
f.launch
else
error message
end if
Another approach if you don’t want the scripts on the user disk is to create constants for the scripts. You can then create a temp file from the constant, launch it and then delete it.