Opening files dynamically


#1

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.


#2

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.


#3

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.


#4

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


#5

@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)

#6


How would i break this loop?


#7

After excel application scope have one break activity