Jump to content

How to point file selection dialog to a directory?


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

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 4771 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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