Renaming Excel files after Sheet names/Cell Values

Hi - I am trying to rename all the Excel files in a folder. Each one is related to a specific company, and that company’s name is present as both a cell value and the name of the sheet. Each file has only one sheet in it.

“Read Cell Value” doesn’t appear to let you select a specific cell without having the sheet name. I have been following a couple of different tutorials but I’m at the limits of my knowledge and don’t know how to proceed.

Basically what I want to do

For Every File in a Folder - only XLSX, but that’s not really necessary
Open the file
Read Cell Value (J23) or Sheet Name, whichever is easier to pull, and store it as a variable
Rename File based on that variable
Move to the next file

You’re missing the Use Excel File activity.

Excel Process Scope

  • For Each File in Folder
    – Use Excel File “CurrentFile.FullName”
    – Get Sheets
    //end Use Excel File
    – Rename file CurrentFile to sheetsVar(0) (ie the first element in the output from Get Sheets
    //End For Each File in Folder

Thanks. When you say “Get Sheets,” how do you execute that? There’s “UiPath.Excel.Activities.ExcelGetWorkbookSheets” which would be great to run but I’m in StudioX and doing this without code. This isn’t one of the activities. So I’m not even sure how to add that code to my workflow, then extract the variable from it.

Please let me know why the following doesn’t work:

For anyone seeing this in the future, make sure to use CurrentFile.FullName instead of just .Name as I was. I’m not sure what the difference is but I think any renaming needs the full file path.

This works:

Is your project set to modern? Get Sheets is an activity.

For a FileInfo variable, there are many different methods and properties. The .Name property gives you just the name of the file. The .FullName property gives you the full path and filename.

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