Save and rename opened excel file

Hi,

I’ve opened an existing excel workbook and I would like to save it with a new name. Is there a simple way to do this?

Regards,

Jeff

@JeffNZ

Is it necessary for the file to be open, if not use move file activity.

In source text box in property give input file path

In destination text box in property give new file path with file name you desire.

Hi,

The process I have is:

  1. Open original excel file
  2. Data is copied into the file.
  3. Save excel file with a different name using the move file activity you mentioned.

Problem I have at the moment is that the original file gets opened which I assume is due to the excel application scope activity I am using. I copy the data in using append range.

The error encountered is “cannot move file as it is being used by another process”.

Regards,

Jeff

@JeffNZ

Use read range activity get data in datatable
Use write range activity write data back to excel

Try this out☺️

@JeffNZ

The best practice is when you use an excel application scope is to always close excel scope after use.

In properties panel you will Workbook output create an variable of type Uipath.excel.workbookapplication.

Then use Close workbook activity and pass the workbookapplication variable you have created. In this way the excel opened will be closed and also the excel.exe instance opened in services will also be closed. Then you will be able to moved file without error.

1 Like

Hi,

Thank you for your response re read and write excel - I’m OK with that thank you.

The problem I’m trying to resolve is to save my edited workbook with a new name while retaining the preexisting workbook.

Flow:

  1. Open workbook “A”
  2. Paste data into workbook “A”
  3. Save workbook “A” with a new name - workbook “B”. Workbook “A” should still exist.

Regards,

Jeff

Hi,

Thanks again for your response.

I actually used the move activity outside of the excel application scope and the file moved. However the problem is that my original file has been overriden. How can I retain the pre existing file?

Also do you have an example workflow for closing excel scope? I don’t quite follow what you are saying there (mainly because I’m an absolute rookie with UiPath).

Regards,

Jeff

@JeffNZ

Do step 1
Do step 2
Save workbook
1st way
Read it again and
Write to excel with new path
2nd way
Use move file activity and
Move your file to another location if you dont want to read it again.

Hi,

Thanks again for your response - really appreciated and really quick!

Having thought about the flow I really need to open workbook “A” and save it immediately as workbook “B” as I do not want to amend workbook “A” at all. Is this possible using the standard excel activities?

Regards,

Jeff

Step 1: create a flow like this.

image

Step 2: create workbook application variable

image

Step 3: Pass created variable to excel scope

image

Step 4: Pass the same variable to close worrbook

image

Hi all.
I’m trying to do the same. Following the instruction @Ragu9060, the original workbook (i.e. “A”) is overwritten.
So the solution is using the UIAutomation with mouse clicks only?

Alt + F + A …For saving a opened Excel file.

Hi All,

I found a solution which works, for that

  1. Make a copy of your initial excel template by renaming using the copy file activity Copy File
    In the destination section mentioned below, change the folder path or file name.
  2. Do your excel processing with the newly renamed file.(writecell,writerange etc)
  3. Use move activity to move to output folder.(by giving input filepath of your copied file name)
  4. Your initial template file remain as is.

hope this helps

how can i use Alt + F + A for saving a opened Excel file.

This is not working in my case, It says file is used by another process. I think that is because I have more sheets in excel and possible it is taking time to copying.

Can you suggest me solution?