Page 1 of 1
Run Filemaker script from LiveCode
Posted: Fri Jan 20, 2012 2:43 am
by trevix
I found on the web this VBScript that should run a script in FileMaker:
Code: Select all
Set objFM = WScript.CreateObject ("FMPRO.Application") 'open FileMaker
Set objFMfiles = objFM.Documents.Open("Z:\Condivisa Mac_PC\ProvaDB.fp7","")
objFMfiles.DoFMScript ("Dialogo")
objFM.Quit
But it does not work.
I tried it also from Access and I got "run-Time error 424, object needed".
Any suggestions ???
Thanks
Trevix
Re: Run Filemaker script from LiveCode
Posted: Fri Jan 20, 2012 5:22 pm
by Mark
Hi Trevix,
You can't create VBScript objects in LiveCode. You need to save the syntax to a file and execute it with cscript.exe.
Kind regards,
Mark
Re: Run Filemaker script from LiveCode
Posted: Mon Jan 23, 2012 10:17 am
by trevix
Thankyou for your answer.
I succesfully use this (stored on a custom property and launched with a "do TheScript as VBScript") to create a new record in Access from LiveCode:
Code: Select all
set MyDB = CreateObject("ADODB.Connection")
on error resume next
MyDB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\CCanagrafica2.mdb;User ID=Admin;Password=;Jet OLEDB:System database = ;Jet OLEDB:Database Password="
SQLString = "INSERT INTO ListaIN (Cognome, Nome, Citta, DataNascita) VALUES ('CognDacercare', 'NomDaCercare',' ','12/12/12')"
set rs = MyDB.Execute(SQLString)
if err <> 0 then
result = "_Error|" & err & "|" & err.description
else
SQLString2 = " SELECT @@IDENTITY"
set rs = MyDB.Execute(SQLString2)
result = rs(0)
end if
set SQLString = nothing
set rs = nothing
MyDB.Close
set MyDB = nothing
and this to run a Access macro:
Code: Select all
Set AccessApp = GetObject("C:\Documents and Settings\CCanagrafica2.mdb", "Access.Application")
AccessApp.DoCmd.RunMacro "GetDataFromMIDA"
AccessApp.Quit
Set AccessApp = Nothing
Why do you say that LiveCode cannot run VB script ?
Trevix
Re: Run Filemaker script from LiveCode
Posted: Mon Jan 23, 2012 10:59 am
by Mark
Hi Trevix,
Please, read my reply again. I never wrote that LiveCode can't run VBScript.
Kind regards,
Mark
Re: Run Filemaker script from LiveCode
Posted: Mon Jan 23, 2012 11:24 am
by trevix
Solved:
I just needed to add Filemaker LogName and password:
Code: Select all
Set objFM = CreateObject ("FMPRO.Application") 'open FileMaker
Set objFMfiles = objFM.Documents.Open("Z:\Condivisa Mac_PC\ProvaDB.fp7","Admin","")
objFMfiles.DoFMScript ("Dialogo")
objFM.Quit
Thanks anyway
Trevix
Re: Run Filemaker script from LiveCode
Posted: Mon Feb 13, 2012 5:15 pm
by Mark
Trevix,
Are you running this with the do command or with cscript? Which version of LiveCode are you using?
Kind regards,
Mark
Re: Run Filemaker script from LiveCode
Posted: Mon Feb 13, 2012 5:44 pm
by trevix
I am using a do command with LiveCode 4.6.4
Too bad is not possible to pass parameters (FileMaker does not accept parameters when the scripts come from outside...)
Regards
Trevix
Re: Run Filemaker script from LiveCode
Posted: Mon Feb 13, 2012 5:49 pm
by Mark
Thanks. Nice that this is possible.
Mark
Re: Run Filemaker script from LiveCode - NEW PROBLEMS
Posted: Sun Nov 25, 2012 5:02 pm
by trevix
Update:
The following code (liveCode 5.5.3) is supposed to launch a FileMaker script (and return eventual errors to Livecode):
Code: Select all
on error resume next
Set FMApp = CreateObject("FMpro.Application")
Set FMfiles =FMApp.Documents.Open("C:\Users\TrevixB\Documents\CC_SaniMont_fm12\CC_preferenze.fmp12","UserName","Password")
If Err.Number <> 0 Then
Set FMApp = Nothing
result = Err.Number
Else
FMfiles.DoFMScript ("Script_ToDo")
If Err.Number <> 0 Then
result = Err.Number
end if
Set FMApp = Nothing
End If
It works fine on the devolpment but, if run from a standalone, FileMaker "believe" that I am trying to open again the file "CC_preferenze.fm12" (not possible since it is already open and shared trough FileMaker) and it wont let me do it (I've checked the script on the standalone and it is the same as on development) :

- Cattura.PNG (10.67 KiB) Viewed 9572 times
The problem, I believe is the CreateObject("FMpro.Application").
It works if I put the script in a text file "thetext.vbs". And it works on the "development" environment but not on "standalone".
I tried to use a GetObject("FMpro.Application") but I've got error (424).
Any idea of what is going on ?
Thanks
Trevix