Excel downloaded file from SharePoint how to edit

I have a download activity which downloads Excel files from SharePoint, and I would like the bot to open the Excel file and make edits - what is the best way of doing that as the output of the download file cannot be inputted into an Excel application scope activity

Hi @E.T.S ,

I believe you would require to use the Folder Path Specified as Download Location with the File Name received from For Each Loop.

Path.Combine("Your Download Location Value",item.Name)

Try Providing the above in Excel Application Scope as the File Path.

However, Maybe you could re-strategise and Let the Download of all the files happen at once, and then use the Directory.GetFiles() method to fetch the Downloaded files from the downloaded folder location and loop it and then perform the Operations on it.

Please could you explain the directory.getfiles() method - I’m not sure how to incorporate that

@E.T.S ,

We would ask you to firstly Check/Test in manner of steps :

  1. First Check if the Download File activity works with the Loop in Place.
  2. Check the Folder Location if the Downloaded Files are present.
  3. (Outside of Loop) Next, Use the below Expression to receive the Downloaded Files from the Download Location mentioned :
downloadedFiles = Directory.GetFiles("Your Download Folder Location Path")

downloadedFiles is of the Type Array of String.

  1. Use For Each Loop activity with downloadedFiles as the value and then check the file paths retrieved.

Perform the Steps One at a time, we will be able to figure out the error/issue at each step easily and understand/provide fixes.

When I tried the Path.Combine(“Your Download Location Value”,item.Name) method I get the error message that item is not declared

When I try the downloadedFiles = Directory.GetFiles(“Your Download Folder Location Path”) method I get the error that directory is ambiguous

All of this works below:

@E.T.S ,

For the above Error Message, I believe you are already able to use the iterative variable (item) in Download File activity and we do not see any errors provided in the Screenshot.

For this one, we would need to use the Full Method / Class Name as the Office365 activities also have Directory methods, so the below Expression should work :

System.IO.Directory.GetFiles("Your Download Folder Location Path")
1 Like

hi @E.T.S

From the first activity where you’re downloading the file.
Please use an Assign activity before that, create a string variable called DownloadPath.
Assign DownloadPath="C:\Users"+Environment.Newline+…
pass download path in Download location and also in the excel Application Scope Path.

That should work for your problem.

Happy Automation!

1 Like