Write Cell Workbook not allowing me to update Excel without closing it first

I am working through the course and we are applying a Write Cell step. The action cannot be completed due to the following exception below. If I close the Excel app, it will update it, but if it is running on its own, it will not update while it’s left open.

Are there any solutions to this? Thank you for your help

Write Cell Workbook: The process cannot access the file ‘C:\Users\CMRN\Documents\UiPath\AmprasFirstBuild\Invoices\Invoice 3.xlsx’ because it is being used by another process.

Hi @Ampra

Before you run the process make sure to close the excel file. This error is raised due to that. You can’t see what’s being written if you go step by step too. If you want to see what’s being written have a message box below Write Cell Workbook and pass the same variable that you are passing in Write Cell Workbook. Whenever the message box appears you can see what is written in excel. Make sure to delete the same message box before you publish or submit your project.

Hope you understand!!
Regards

Well that’s true
You can update the excel through bot only when only someone has saved and closed it

Here instead of using write cell workbook use EXCEL ACTIVITIES so that you don’t need to open and close once after every edit in the workbook as that is what is happening now

Have a view on this for more details

Before excel activity named USE EXCEL activity use a KILL PROCESS activity before that Excel application scope or Use excel activity
Where in ProcessName mention as “Excel”

It’s very important to ensure that the entire thing is contained within an excel scope? This will keep the file open until you say you wish for it to be closed. The error is popping up because you are closing/opening excel each time and that takes a long time, but the robot moves so fast that it tries to open it while the previous one is still closing, thus throwing the error.

Cheers @Ampra

Hi,

FYI, If you are using the latest Excel activites package 2.22.0-preview or higher, can you try the following?

Create WorkbookApplication type variable at Workbook in ExcelApplciationScope.

img20230911-3

Then set it at Workbook property in WriteCellWorkbook activity.

img20230911-2

Regards,

Man… this is extensive for a simple write step. I’m new to the program and am never sure of which Write Cell to be using. They all function different but should be performing the same thing lol.

Losing hope with this. The course uses step name ‘Excel Application Scope for each Invoice Sheet’, but you are suggesting I use ‘Use Excel’ instead to launch the app?

The inconsistency among versions, packages and steps puts everything in a spiral.

I have the file closed when I run it, but in the process, it opens the file automatically as intended. This is so the robot can apply the Write Cell steps to the file.

I am using step ‘Excel Application Scope for each Invoice Sheet’ and it is launching it from there.

Thank you

Hi @Ampra

You are using Write cell workbook right remove that and use Write Cell. Since workbook don’t allow to keep the excel open and will throw an error.
Check out below image for reference.

image

Regards,

Can you share the screenshot of workflow with activities u have used
@Ampra

Definitely! Are you requesting to see mine?

Yeah share ur workflow screenshot with the sequence of activities visible
@Ampra

I gave that one a shot @Parvathy , however I don’t think I have the same “Write Cell” activity as you do. This is the list I am given when searching :

and the details of this one looks like this:
image

Hi @Ampra

Are you using classic activities or Modern activities. Specify so that I can help you.

Regards,

Of course, this is what we have:


The one I sent you was modern, I believe. There was no “Classic” showing for that step when I selected it from the list. @Parvathy

You used the right activity @Ampra

Regards,

Is there a proper way to reference the cell location? I’m unsure how to convert it to ‘IReadWriteCellRef’ @Parvathy

You need to give like below:

Excel.Sheet("Sheet1").Cell("E18")

Make sure to remove Write Cell Workbook.

Regards.

I tired re-using the expression to reference the sheet and it doesn’t seem to like it. After removing those end-parentheses the exception still remains.

Is this a traditional way to complete this expression or do you think my syntax is off?

Thank you, @Parvathy

Fine

U r using EXCEL APPLICATION SCOPE and passing the filepath
Then why u r using WORKBOOK activities like WRITE CELL WORKBOOK where again u r passing the filepath to update

Ideally u have to use EXCEL based activities and not workbook activities

There are two set of activities package to edit or read a workbook

  1. Excel activities - this works only if excel app is there
  2. Workbook activities - this works even if excel app is not installed

This is the basic difference

As you are opening the excel file with excel application scope inside that again you are trying to open it with workbook activity which will obvious throw that the file is already opened

You are using excel application scope
So let’s use only the excel based activities not the workbook

Search in activity panel as excel where you can see set of activities under the category called excel
Under that choose WRITE CELL activity and use it
Remove the write cell workbook activity that you had earlier

Inside the write cell activity you can mention the cell where u wanna write
Click on plus symbol in the field and mention the cell where u want to type the value

Cheers @Ampra

@Ampra

Give the syntax that I have given above as you are using the excel file by using the activity Use Excel File.

Regards,