Error for move file to folder

Hi, I need to check number in excel file and if no error will move the file to a folder else will move to another folder. Below are the Ui path i trying and the error i get. Thanks .

You should move For Each block out of Excel Application Scope.
In Excel Application Scope, this file is openning, so you cannot move it.

One more thing, there’s problem in you code logic
Because the Move File is in For Each, so it will be executed many times
But the file was moved in the first round, so it can make an error too

Oh i see, but how should i move the file to another folder after the for each row checking is done?

Let me confirm about your rule
In column A, there’re many values, right?
So which data you base on to give moving decision? the lowest value or the biggest value?
Example, in case the data is below, where will you move your file to? <10000000’s folder or >10000000’s folder?


The rule is,

If all the values in column A are >10000000, then the file will move to >10000000 folder.

Else if have one of the value in column A is <10000000 the file will move to <10000000 folder.

Please check my sample code

Main.xaml (8.2 KB)

Thanks for patient teaching !! :smiley:

I still have one more question, if let say i want change the >10000000 to = 8 digit. What should i write for the if condition?

item.ToString.Length = 8

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.