Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to point file selection dialog to a directory?

Featured Replies

A few months ago, a post on this forum confirmed the rather lame, but apparently "standard", method to capture a user-selected file name into a FileMaker field:

Create a global container field (e.g. gScriptFileIO) ... In a script navigate to a layout containing that field. Use the script step:

Insert File[Reference;MyTable::gScriptFileIO] without specifying a source file.

Then GetAsText() on the container field to parse the file reference.

Does anyone know of a way to point the Insert File (file selection dialog) to a particular directory?

I have a standard directory that always contains a set of imported files. All the user needs to do is select one of them. It seems absurd (to them and me) that the computer can't always point them to the proper directory. I've attempted to do this by specifying a non-existent file on the correct directory. But that gets derailed by any previous (unrelated) file selection if that selection was elsewhere on the disk.

BTW, I don't need a cross-platform method. This is only for Windows ... but I do need a method that doesn't involve a plug-in.

Thanks in advance for any help.

Attached is an old demo on how to do this with VBscript from inside FM. The problem with not using a plugin is that when you execute the VBscript, FM is not waiting for it to finish or for the result. A VBscript can call a FM script to import the result, which is what this demo does. But the FM ActiveX interface has become buggy every since FM 7 so test thoroughly. Especially try the routine many times in a row.

The other way of getting the result back into FM is to put FM in a loop after executing the VBscript and try to import the resulting file until it works (or until you decide to get out of the loop after x seconds).

You'll need a slightly different Windows call to select an individual file, I'll see if I have demo for that laying around.

VBscript_folderContent.zip

Here's the VBscript that lets you pick a file and return the name


Set objDialog = CreateObject("UserAccounts.CommonDialog")



objDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"

objDialog.FilterIndex = 1

objDialog.InitialDir = "C:\"

intResult = objDialog.ShowOpen

 

If intResult = 0 Then

	Wscript.Quit 1

Else

	Wscript.stdout.write objDialog.FileName

End If





You'll need to change the



Wscript.stdout.write objDialog.FileName

piece by something that writes to a text file for importing into FM

  • Author

Thank you very much for the comprehensive reply, especially the cautions. I'll step back and evaluate a plug-in that I've downloaded (although I'm not enthusiatic about having another component to keep up with).

It seems ironic that FileMaker puts so much emphasis on connecting to the world (with IWP) and so little on connecting to the environment of the Windows PC it's running on. I just went through an evening of unravelling the differences in the "slashes" on file referencing (filewin://c:/ versus c:\ ), which reminded me how rudimentary the advertised "cross-platform" capabilities really are at the nuts and bolts level. But, hey, maybe they're working on them. We can hope.

Thanks, again.

I've attempted to do this by specifying a non-existent file on the correct directory. But that gets derailed by any previous (unrelated) file selection if that selection was elsewhere on the disk.

How about doing it the other way round: export a dummy file to the correct directory, insert it back - then show the insert dialog?

  • Author

... export a dummy file to the correct directory, insert it back - then show the insert dialog ...

That sounded good ... but I can't make it work. I built the simplest of steps (paraphrased here):

Export Records[no dialog; DesiredPath\Simple.tab ]

Insert File[ from DesiredPath\Simple.tab ]

Insert File[ ... with no path specified ]

The tab file exports and inserts fine. But the default directory for the second insert remains the last one the user selected from. So, Windows must keep scripted selections separate from user selections.

Have I missed something?

Alas, you are right: I thought it would go to the last directory used - but it looks like it goes to last directory used manually.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.