February 9, 200619 yr Description: The demo file shows how to use VBscript to pop up a "browse for folder" OS dialog and return the path to the selected folder and a list of its files back to FileMaker. Working Under: 8 Advanced Solution Status: Finished Pre-requisites: FileMaker 8 Author(s) Wim Decorte Date: 02/09/06 Credits: Instructions / Other Info: It clearly shows the challenges of using VBscript with FileMaker on Windows: - generating the VBscript syntax - creating the VBscript file on the hard disk & executing it - returning a result back to FM (using the import engine, but not creating any new records) Disclaimer: FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify. VBscript_folderContent.zip
February 9, 200619 yr Hi Wim, Thanks very much for this example it is great! I haven't tested it as yet but it is a really helpful example for someone who is a mac specialist and now has to deal crossplatform. Thanks again Lance
February 10, 200619 yr It's fairly simple to get the list of files in AppleScript. But it depends what you want, and what you want to do with the results. Just the names? (These can be added to the folder, to produce a full path.) set theFiles to list folder (choose folder) without invisibles An Applescript list of files (in Finder syntax): tell application "Finder" set theFiles to files of (choose folder) end tell Or, in alias syntax, which is much the same, but looks better: tell application "Finder" set theFiles to files of (choose folder) as alias list end tell Or you can get a list of the full paths in a return-separated list, which can then be set into a global field. That needs a little more work (I've commented out the FileMaker part, as you'd need the field): tell application "Finder" set theList to files of (choose folder) set newList to (item 1 of theList as string) repeat with i in theList if i is not item 1 of theList then set newList to newList & return & (i as string) end if end repeat set newList to newList as string end tell (* tell application "FileMaker Pro Advanced" set cell "_gFiles" to newList end tell *) This example file Inserts the files in a folder. It's 8-only. Insert_Folder_Files.zip
February 11, 200619 yr Thank you so much, Now I have answer to some of my questions. And, VBScript with AppleScript can greatly extend FM possibility in both platforms!
June 26, 200619 yr I am trying to figure out how to get this script into my database. Can someone help?
June 29, 200619 yr Seriously, this script looks like my best bet, but i do not know how to get this functionality into one of my databases... can someone walk me through it?
June 29, 200619 yr actually, although this is close, because this does store the path into a field, but this just scans a folder and dumps the contents of the entire folder. I would also need to be able to select a file, not just a folder, and have the path to the file be in one field and the file name you selected in another field. any takers?
June 30, 200619 yr This was realy nice. I will use it for keeping track of my invoice copies stored on the harddisk. Thanks. Edited June 30, 200619 yr by Guest
July 9, 200619 yr Author Not sure what is not working for you. You can copy the table, fields and scripts over... or even recreate them manually (like you have to for the layouts and custom functions)...
July 9, 200619 yr Author You need a different kind of VBscript for selecting a file. But the rest of the logic stays the same. For an example VBscript that selects just one file, download the VBScript demo db at www.grokittools.com
August 3, 200619 yr Just a smidge off-topic, but if you really want to have some fun with FM and VBScript, grab this: Script Kit Enjoy! There are about 2200 scripts that do everything from create, populate, and print Word docs to adding/deleting users from an Active Directory. I got these from the MS Script Repository, imported them from Access into FMP (via ODBC), and wrote up a little something to run them.
August 4, 200619 yr Author You'll find the same thing on the downloads page of my website: www.connectingdata.com. Called VBscript repository...
August 1, 201312 yr Hi Wim, Thanks for this great example.... its works great ...but one things i dnt undrstnd..nd that is...how u stored the selected folder's path in return path field ..?
August 1, 201312 yr Author The VBscript creates a CSV file on the hard disk and the FM script imports that.
August 2, 201312 yr yeah ..But how u get the path(value) of the return path....? and i want to show file also in browse th folder dialog box...but user can select only folder ..this thing is possible with script or without VBscript... ?
August 2, 201312 yr suppose this ...code for show files in dialog box Dim objShell Dim strFileName Dim strFilePath Dim objFile Set objShell = CreateObject("Shell.Application") Set objFile = objShell.BrowseForFolder(0, "Choose a file:", &H4000) strFileName = objFile.Title strFilePath = objFile.self.Path MsgBox "Just the file name: " & strFileName & vbcrlf & "The full path: " & strFilePath Set objFileName = Nothing Set objFilePath = Nothing Set objShell = Nothing now how to store selected item's path in fm databse... please write down the steps.. thank you
Create an account or sign in to comment