Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4130 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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!

  • 4 months later...
Posted

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?

Posted

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?

Posted (edited)

This was realy nice. I will use it for keeping track of my invoice copies stored on the harddisk.

Thanks.

Edited by Guest
  • 2 weeks later...
Posted

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)...

Posted

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

  • 4 weeks later...
Posted

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.

Posted

You'll find the same thing on the downloads page of my website: www.connectingdata.com. Called VBscript repository...

  • 6 years later...
Posted

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 ..?

Posted

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... ????

Posted

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 New...

Important Information

By using this site, you agree to our Terms of Use.