Ted S Posted June 7, 2004 Posted June 7, 2004 I'm running Windows XP with FileMaker 6.0. I would like to have a (Windows) scheduled task run a FileMaker script at regular intervals. I'm pretty sure this can be done with vbscript (WSH). FileMaker has an example in the help section on how to do this but it's written for VBA not VBS and I think the syntax must be a bit different between the two "vb" languages. Here's where I am so far: Dim FMApp, FMDocs, FMActiveDoc FMApp = FMPRO50Lib.Application FMDocs = FMPRO50Lib.Documents FMActiveDoc = FMPRO50Lib.Document 'Launch FileMaker Set FMApp = CReateObject("FMPRO.Application") 'Set the Documents Object Set FMDocs = CReateObject("FMApp.Documents") 'Make FileMaker visible FMApp.Visible = True 'Open a file myOpenFile = FMPRO50Lib.Document Set myOpenFile = FMDocs.Open("c:FileMakerPart.fp5", "") 'Run a script myOpenFile.DoFMScript("Import_All_Parts") 'Cleanup Set FMDocs = Nothing Set FMActiveDoc = Nothing Set myOpenFile = Nothing FMApp.Quit Set FMApp = Nothing It doesn't work. Any ideas? Thanks,
jrb12 Posted June 7, 2004 Posted June 7, 2004 Ted, Hope this doesn't turn out to be good intentioned road kill. I get the feeling your FileMaker app, Part.fp5, is not running on a regular basis. That you are opening it up just to run the script then closing it again. If this is correct, why not set your task in XP to run Part.fp5 itself on a regular basis. Put your script in as the startup script. The script can finish by quitting the application. I haven't actually tried this mind you, but it does seem reasonable. Cheers, John.
Ted S Posted June 7, 2004 Author Posted June 7, 2004 The script listed I just copied from FileMaker help and massaged a bit because it didn't work right-out-of-the-box. The Part.fp5 file will be operational 24 x 7 so I really don't need to open the application but for future reference I would also like to know how to open and close the FileMaker App via a script.
jrb12 Posted June 7, 2004 Posted June 7, 2004 Ok, WSH doesn't have access to the FMP type library and in general does not need to have its objects defined like in VBA. Try this trimmed down version of the script: Dim FMApp, FMDocs, FMActiveDoc 'Launch FileMaker Set FMApp = WScript.CreateObject("FMPRO.Application") 'Set the Documents Object Set FMDocs = FMApp.Documents 'Make FileMaker visible FMApp.Visible = True 'Open a file Set myOpenFile = FMDocs.Open("c:FileMakerPart.fp5", "") 'Run a script myOpenFile.DoFMScript("Import_All_Parts") 'Cleanup - close the documents first so the app will close FMDocs.Close Set FMDocs = Nothing Set FMActiveDoc = Nothing Set myOpenFile = Nothing FMApp.Quit Set FMApp = Nothing Cheers, John.
Recommended Posts
This topic is 7735 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now