Opening files dynamically

Hi All,

I am new to UI Path.

Is there a way to open the first excel file within a folder dynamically (e.g. *.xslm) without looping.

You mean opening all files which are present in folder OR one file at a time, but the file name is dynamic. Incase of later one you can use a string variable to store the name of file and specify the string variable in place of file name in app scope.

One file at a time but the file name is dynamic.
e.g. the files will be added in daily but there is no structure to the filenames.

if you know exactly the folder name
Directory.GetFiles(“Path”)

you can get all file names in array and loop through it with if condition file.extention=(“.xlsx”)
once it is matched you can break the loop

@chend
What @Divyashreem said will work. But that contains looking through the files in the folder.
Please follow below steps if you know the file you need to open will be in first position always-

  1. Get all files from folder with .xslm extention,
    arFiles = Directory.GetFiles(“Path”, “*.xslm”)
    Result of this activity will be array of strings
  2. Check array contains elements => folder has .xslm files
    arFiles.Length > 0
  3. Get file file to open, arFiles(0)
2 Likes


How would i break this loop?

After excel application scope have one break activity