Allow user to select file name (Open file name picker dialog)

From a PRO user by email:

Hi, looking for a way to prompt and ask for a csv file to open. Is that possible?

The prompt command does not let me select existing files on hard drive

The XRUNandWAIT command allows you to start any external script, and it can help here.

In the demo below I start a small Powershell script that opens the FileDialog. The result is stored in a text file. Back inside the macro we read this text file with csvRead, and then have the file name with full path in ${!COL1}.

Powershell script “getfilename.ps1”:

Add-Type -AssemblyName System.Windows.Forms
$f = new-object Windows.Forms.OpenFileDialog
$f.InitialDirectory = pwd
$f.Filter = "CSV Files (*.csv)|*.txt|All Files (*.*)|*.*"
$f.ShowHelp = $true
$f.Multiselect = $false
[void]$f.ShowDialog()

Write $f.FileName
Set-Content -Path 'c:\test\text.csv' -Value $f.FileName
[Environment]::Exit(1)       

Macro:

{
  "Name": "OpenFileDialog",
  "CreationDate": "2020-6-22",
  "Commands": [
    {
      "Command": "echo",
      "Target": "Demo script for file name picker",
      "Value": "green"
    },
    {
      "Command": "XRunAndWait",
      "Target": "Powershell.exe",
      "Value": "-executionpolicy bypass c:\\test\\getfilename.ps1"
    },
    {
      "Command": "echo",
      "Target": "Powershell return code ${!xrun_exitcode}",
      "Value": "blue"
    },
    {
      "Command": "comment",
      "Target": "Powershell script stores file name in text file => read it as CSV file",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "false",
      "Value": "!StringEscape"
    },
    {
      "Command": "csvRead",
      "Target": "c:\\test\\text.csv",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Selected file name = ${!COL1}",
      "Value": "blue"
    }
  ]
}

is it possible to use these steps and then use XrunAndWait to run selected file?
Or can Xrun and wait be used to open an excel file with a specific name in a specific location
Test.xlsb in C:\test\

You always want XRRUN & XRUNandWAIT to start a script that then does what you want (open excel file, etc.).

See: https://ui.vision/rpa/docs/xrun

this documentation does not specify how to open a specific file, only open the program
Could you please describe how you would open a specific excel file in a specific folder location?
Or how can i use your code above to select the file then Xrun or XrunAndWait?

Because that wouldn’t be the job of UIVision, the script would do that.
What language?