Amram Chayim Eirinberg Posted February 19, 2010 Posted February 19, 2010 Hi All, I have experience with VBA for MS Excel. I would like to write some VBScript and connect it to FM. My question is how do you do this? I would imagine that you create a vbs file in notepad but then how do you connect this with FM? And do you need FM Advance? Any help will be very much appreciated!
IdealData Posted February 19, 2010 Posted February 19, 2010 I would like to write some VBScript and connect it to FM What do you expect to do with FM when you "connect" to it?
Amram Chayim Eirinberg Posted February 20, 2010 Author Posted February 20, 2010 Let’s just say I want to run the following: msgbox "This is a Visual Basic Script file" Basically I just want to know how to connect a JBS file whatever may be in that file as long as it has valid VB script
aholtzapfel Posted February 23, 2010 Posted February 23, 2010 The object madel for filemaker does not let you do alot. You can do the following: Open/Connect to filemaker Check if a script is currently running Make Filemaker visable Open a file (cannot open a hosted file) Execute a script (cannot pass parameter and script folders can cause the wrong script to be called) Here is a simple sample of a vbs script. Set objFM = WScript.CreateObject ("FMPRO.Application") 'create FM object If objFM.ScriptStatus = 0 then 'test if a script is currently running Set objFMfiles = objFM.Documents.Open("C:pathTOfileYourFile.fp7","username","password") 'open FM file objFM.Visible = True 'make sure FM is visable objFMfiles.DoFMScript ("ScriptName")'preforms a FM script End If 1
Wim Decorte Posted February 25, 2010 Posted February 25, 2010 Can you explain a little better exactly what you want to do? A VBscript can touch FM from the outside and some some things. You can also construct and run a VBscript file from inside FM and touch things outside FM (like Excel,...) Which of two are you trying to accomplish?
Amram Chayim Eirinberg Posted February 26, 2010 Author Posted February 26, 2010 It's the later one Wim, I'd like to run vbs file from within filemaker
aholtzapfel Posted February 26, 2010 Posted February 26, 2010 Here is a sample file. This might help you get started.
Wim Decorte Posted February 26, 2010 Posted February 26, 2010 in addition, there are a few VBscript plugins out there that'll help you out. You can also check out the downloads section on my website: www.connectingdata.com and some of the other posts in this section of the forum. It does include some samples of doing just that.
Newbies ryan thompson Posted June 23, 2013 Newbies Posted June 23, 2013 The object madel for filemaker does not let you do alot. You can do the following: Open/Connect to filemaker Check if a script is currently running Make Filemaker visable Open a file (cannot open a hosted file) Execute a script (cannot pass parameter and script folders can cause the wrong script to be called) Here is a simple sample of a vbs script. Set objFM = WScript.CreateObject ("FMPRO.Application") 'create FM object If objFM.ScriptStatus = 0 then 'test if a script is currently running Set objFMfiles = objFM.Documents.Open("C:pathTOfileYourFile.fp7","username","password") 'open FM file objFM.Visible = True 'make sure FM is visable objFMfiles.DoFMScript ("ScriptName")'preforms a FM script End If Hi everyone, if you're still here. I'm a few years late to the party, and I'm total noob to vbs, but I've got something that's doing everything I need up until this point (which I largely found here, thanks!).. Function runFileMakerImport objFM.Visible = True 'WshShell.AppActivate ("FileMaker Pro ") ' Set objFMfiles = objFM.Documents.Open( "C:~practice DBsBlackHorse.fmp12","admin","") objFMfiles.DoFMScript ("import") End Function using echo, I've found the last line does nothing as written above (lines 3 & 4 being commented out). If I uncomment those two, then it ceases at the first commented-out line, the appActivate function. Here, http://www.filemaker.com/help/html/create_script.12.12.html, I've read that I need to do some work to get the vbs library, but I don't know if I'm correct, and if so, I don't know how to do that. I'm writing my vbs in notepad, the website referenced wants me to open some 'project menu' in 'visual basic'..? Also, my limited experience in vbs indicates that the appActivate function needs a string that matches what the window says, and what task manager says. Which in my case is "FileMaker Pro Advanced [blackHorse]" and this is more specific than the above code. Is this a problem? Any guidance is much appreciated, as is the work and sharing you all have already done! Sorry for any possible faux pas, this is my first reply/post in this forum and one of only a few total. Edit: Nevermind! I figured it out! BTW, I had the createObject line at a global level so it wasn't shown, also, it was late I guess, but this morning I see I commented out the set objFMfiles, and then tried to use it. When I brought back in line 4 above and left 3 out, it works! hooray! I didn't erase this post just because I wanted to say a big thank you to you all! Thanks!
Wim Decorte Posted June 23, 2013 Posted June 23, 2013 The example in the FM help assumes that you are using Visual Basic 6. That's a totally different animal than VBscript. The snipped of code that you've posted: does it have more preceding that? If not then here's a few things with it: - you are not instantiating objFM before you use it. That's what you need this for Set objFM = WScript.CreateObject ("FMPRO.Application") 'create FM object - there is no need to use WshShell.AppActivate ("FileMaker Pro "). FM will listen to the commands you send even if it is not the frontmost window - objFMfiles.DoFMScript ("import") will not do anything because you have not instantiated "objFMfiles". The line where you do it is commented out
Newbies ryan thompson Posted June 23, 2013 Newbies Posted June 23, 2013 The example in the FM help assumes that you are using Visual Basic 6. That's a totally different animal than VBscript. The snipped of code that you've posted: does it have more preceding that? If not then here's a few things with it: - you are not instantiating objFM before you use it. That's what you need this for Set objFM = WScript.CreateObject ("FMPRO.Application") 'create FM object - there is no need to use WshShell.AppActivate ("FileMaker Pro "). FM will listen to the commands you send even if it is not the frontmost window - objFMfiles.DoFMScript ("import") will not do anything because you have not instantiated "objFMfiles". The line where you do it is commented out On point! Yes, there is a bunch of stuff preceding the function I pasted, and at the top I instantiate objects for several functions.. removing the appActivate and bringing back in the line that sets objFMfiles got me rolling, thanks!
Newbies ryan thompson Posted July 24, 2013 Newbies Posted July 24, 2013 Hello all, again, I just have one more question.. I've been using vbs with FM with great success, thanks in large part to this community! I am curious though if anyone has any literature on the FM object in VBS. I've got a sporadic issue with my FM12 solution, that causes users' FM application to totally freeze up.. It has to do with modal windows, but that's not the point.. I'd like to be able to run a vbs file (or anything) that could tell me about the call stack on the user's FM app. Currently, I can run a file that tells me how many scripts are running, but I'd really like to know which ones! Here's what I have.. Either a direct answer or a pointer to some reading on the FM app VBS object would be much appreciated! on error resume next dim objshell set objFSO = CreateObject( "Scripting.FileSystemObject" ) Set objShell = Wscript.CreateObject("WScript.Shell") Set objFM = WScript.CreateObject("FMPRO.Application") Function CheckForScript wscript.echo objFM.ScriptStatus End Function CheckForScript Thanks!! Ryan
Newbies ryan thompson Posted July 25, 2013 Newbies Posted July 25, 2013 Thanks Wim, looks like I can't do exactly what I was hoping to do.. not a huge surprise since the debugger is the only avenue to view the call stack even when you're in FM. FWIW, I did find a good site on the FM object, it's more generally for ActiveX, but this supports vbs (may not be saying that correctly, but that's my understanding). http://www.filemaker.com/12help/html/create_script.13.12.html With this I'm able to loop through the open files and see whether they're 'active'.. haven't applied it to my problem yet, but I'm excited to see if it proves helpful. Here's my code, you'll notice several lines commented out as they were part of my exploration of the FM object but are not relevant to my present application. Thanks again Wim and all! on error resume next Dim app Dim i Dim docs Dim x Dim f1 Set app = CreateObject("FMPRO.Application") set docs = app.Documents i = app.Documents.count x=1 'wscript.echo "number of open files " & i 'wscript.echo "this is the caption property of the application object " & app.caption 'wscript.echo "name " & app.Name 'wscript.echo "full name " & app.FullName 'wscript.echo "defaultFilePath " & app.DefaultFilePath 'wscript.echo "version " & app.Version wscript.echo "script status " & app.scriptstatus for each f1 in docs wscript.echo x & ": " & f1.FullName & ", active: " & f1.active x = x + 1 next Set app = nothing set docs = nothing
Macfreq Posted July 21, 2015 Posted July 21, 2015 in addition, there are a few VBscript plugins out there that'll help you out. You can also check out the downloads section on my website: www.connectingdata.com and some of the other posts in this section of the forum. It does include some samples of doing just that. Wim, do you still have the examples available somewhere? I can't find a downloads section on your website. I'm trying to execute a VBscript from within FileMaker Pro 13 so I can in turn execute an Adobe InDesign VBscript automation script and return any errors back to FileMaker Pro 13. I can do this now on a Mac with AppleScript and an InDesign automation AppleScript, but I need to port the process to Windows 8. Thanks for help. Tom
Wim Decorte Posted July 21, 2015 Posted July 21, 2015 I'm sure I can find them. But these days you're probably better off going with PowerShell instead of VBscript, unless Adobe InDesgin has no PowerShell API? Try and find that out first. No use going with an old technology if a new one is available.
Recommended Posts
This topic is 3453 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