Error while passing the variable in the code

Hi, I am passing the variable item in the code but it’s showing me the error while executing that activity. But the value is coming from the item is correct. If give the direct path in the code it’s working fine. But when I pass the variable inside the code in the place of path giving then it has thrown me the error while item is giving me the correct folder path and file name.

see what value is printing item. It is the correct value which I want folder name with file name.

Now I am executing the Code stage it will throw an error.

How I pass the value in the parameter and code.
image
image

Kindly help.
@HareeshMR @Palaniyappan @Lahiru.Fernando @lakshman @KarthikByggari

1 Like

Fine the way the variable passed is right
but the value passed with is wrong it seems
kindly check once the path and validate whether it is correct or not
its getting failed while trying to open that file under the path mentioned

you were almost done buddy
Cheers @balkishan

1 Like

Try a message box in the for each loop and in the code as well

In code: system.windows.messagebox.show(filepath)

see bro before code stage I just used Excel Application Just to check whether the value coming from the item is correct and it read the file. But it read the file correctly it open the same excel file if you see the Excel Application Scope is executing and open the file.

But same variable I am passing the code it’s giving me file error says that the file is removed or modified.

@HareeshMR

1 Like

Bro…It’s giving the correct path with file name. even I used in the Excel Application Scope just to check whether it’s readable or not but it’s reading correctly…same item I have passed in the Excel Application Scope.

1 Like

@Palaniyappan The given path is readable bro. See I pass the same item variable in the excel scope application and it’s working, it open the same file.

But when I pass the same item variable in the code it doesn’t working and thrown an error which I already attached the snapshot.

Please help

1 Like

hmm. …this is strange
Fine may i know where this item variable is obtained from
then you say it works
Cheers @balkishan

1 Like

From the folder only bro.
where I have multiple files and I always want this file to be pick so I give the condition.

And it’s giving me the correct file path with name. same item variable I am passing. As I have given in the Excel Scope it’s working. But when give in the code it’s saying file is removed or not there…

1 Like

Fine
assign that item to a string variable and pass that variable to invoked code and try once
Cheers @balkishan

1 Like

Not working bro…

I don’t know why it is not getting the full path :thinking: @balkishan.

Everytime we will get the full path. the thing is that, as we are using the code, it won’t recognize the path if we give short , we have it give it clear :slight_smile:

1 Like

No, If give the direct path then only it’s work, Like item variable printing the path.If I give this complete path then it work. But My file name is changing at last so I can’t give the direct path na. If everytime I got the same file then direct path I can give but here it’s problem.
Any solution for this…

You are not giving direct path. You are passing in a variable bro. I’m asking you to pass the full path in the variable itself :slight_smile:

1 Like

Bro my file is name is diff. It will work only for specific file not for all. I can pass the full path but my file name is not same this is the reason.

it’s showing the full path in the code activity.
image

If I manually mention this path in the code it will execute…
master_template\AMAZON FILE TEST1234 - COD & E-Paymt final 25 July s.xlsm

But the problem is last bold name will be changing on date wise.

But why it’s not reading the excel file.

You see, this is the entire path what I mean. If we give path as only Data.xlsx in code, it will throw the same error, so we need to pass entire path…

image

1 Like

That’s not a complete FilePath, just the path of the item in your directory.

Also, if your filename is formatted in the same way everyday, you can make that part of the path relative, something like:

"master_template\AMAZON FILE TEST1234 - COD & E-Paymt final" + DateTime.Today.ToString("dd MMMM") + " s.xlsm"

Cheers, Lukas

Hi, It’s working when I gave the full path. Thanks

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