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 select a file in Windows Explorer?

Featured Replies

I have a script that opens a folder on a network volume. The intention is to open the folder and attempt to select the file. If the file can't be selected, it's OK—I'm not going to bother the user with an error message. I have this working on the Mac side via AppleScript, but I can't get the file select portion working on Windows. Here are my relevant script steps:

#Folder was opened successfully - Now attempt to select the source file as a nicety

Set Variable [ $select_file_path; Value:$successful_url & $part_number & $part_revision & $file_extension ]

If [ Abs(Get(SystemPlatform)) = "1" ]

#Mac

Perform AppleScript [ Calculated AppleScript: "tell application "Finder"¶ reveal "" & $select_file_path & ""¶ end tell" ]

Set Variable [ $select_error; Value:Get(LastError) ]

Else

#Windows

// Open URL [ "explorer /select, "" & $select_file_path & """ ] [ No dialog ]

Send Event [ open document; "explorer.exe /select, "" & $select_file_path & """ ] [ Bring application to foreground ]

Set Variable [ $select_error; Value:Get(LastError) ]

Show Custom Dialog [ Title: "debug"; Message: "Error: " & $select_error & "¶" & "explorer.exe /select, "" & $select_file_path & """; Buttons: “OK” ]

End If

The $select_error returns 0 on Windows, but the file is still not selected in the folder that opens up. Here is the exact error message (screenshot attachment upload isn't working):


Error: 0

explorer.exe /select, "10.0.0.19LSI Engineering017-XXXX-XXXX-XX017-0000-XXXX-XX017-0000-02XX-XX017-0000-0266-00.eps"

Am I right in using the Send Event script step? I saw in another thread that one could use cmd /c del to delete a file, but I couldn't find an appropriate command to select a file ("goto" doesn't seem to be right).

is the purpose to try and get the file into FM or just to show to the user?

If the file is not being selected, you do not have the correct path/filename/extension. The /select switch you have used, IS the proper syntax to select the file, if it exists, using explorer.exe.

Note, however, that the way you have it written, the Explorer window will not come to the foreground, even though you have [bring Application to Foreground]. In this particular case, with explorer.exe, to bring the explorer.exe instance to the foreground, the entire command must be prefixed with CMD or preferrably CMD /C, e.g. CMD /C explorer.exe /select, "path_and_filename.ext". Try Start|CMD and pasting the command into a DOS Window first. If you do not prefix with CMD, the explorer instance will still open, it just won't be in foreground.

Unfortunately, Send Event will not report errors; Get(LastError) only reports errors originating in Filemaker. This is why it always reports zero, even if the command you send, has errors. So this logic won't work.

Thus, you must test for file's existence, prior to running Send Event. This can be done by attempting to import it and trapping the error if not found, use of MooPlug, ScriptMaster, or numerous other means. If you want to import it then it needs to go into a container since that will be capable of displaying the EPS image. If file can't be found, you may want it to just open the directory file was supposed to be in.

I recently did some work with MS Access, one feature I liked, was the ability to drag/drop files to table & retrieve their name/path using VBA.

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.