Good day,
I have studio 2025, and would like to use modern activities to check if the sheet name exists in the excel file. I have some activities I have used for it but the issue is excel stays open then when it gets to Read range activity it errors because of that open file. Is there a way to check for an existing sheet and also to write onto the excel file column in the background..
@Anelisa_Bolosha1
Hi, If your excel remains open after getting sheets, You can Kill Process activity to kill the excel process. It will close it and you can read it.
Hi @Anelisa_Bolosha1 ,
The issue is likely happening because Excel remains attached/open within the Excel Application Scope, so when another activity tries to access the same file, it may encounter a lock.
Try the below steps:
Use Use Excel File activity instead of Excel Application Scope.
Get all sheet names using Get Workbook Sheets.
Check whether the sheet exists:
sheetNames.Contains(“Fail”)
If the sheet exists, use Read Range and Write Range/Write Cell inside the same Use Excel File container.
Enable Visible = False (or disable opening Excel) to work in the background.
You can surround the Read Range activity with a Try Catch block. In the Catch block, handle the System.ArgumentException and check the exception message, which will indicate that the sheet does not exist.
This way, you can handle the missing sheet scenario gracefully instead of letting the workflow fail.
I think that the issue is that you use an Excel Application Scope which opens the file, then down further down the process you use a Read Range activity that is not meant for the Excel Application Scope. It tries to open the file again - which it can’t because it is already open.
If you in the Activities list in Studio Search for ‘Read Range’ then you should find at least two ‘Read Range’-activities. You should use the on where you don’t have to give the filepath again.
The correct Read Range will not need a filepath because you already gave it in the Excel Application Scope.