Read/Write to Excel file while it is open

Hi there,

I have built a bot for my employer which writes to a report file of the success/failure of each transaction and some details about any error messages that may appear. Somebody would manually go through the reports and check on any of the exceptions (“Failure”) the bot was unable to process.

The bot runs 24/7 and writes this as a daily file with today’s date.

However, if somebody has today’s report file open (.xls), the bot will crash or unable to write to file as it tries to “Read Range” to check the number of rows so it can write to “lastrow + 1” say.

How can I have the bot reading/writing to an excel file which may be open by another user at the same time?

1 Like

Bump. Anyone able to help?

I gathered that by using Excel Application Scope, I can read from the file while it’s open.

But the thing I’m stuck at is trying to write to the file while it’s open. At the moment I’m getting “Type mismatch” error when I have it open on a different machine while the bot attempts to Append Range. Worst case scenario, maybe I’ll use a Try/Catch and if there’s an error I will just write to a new file for each line: for example "Report_1.xlsx " and append with the policy number (or something unique) of the line it was trying to write out.


(Assuming they dont need to edit the file) Not an expert but could you get them to view the Excel file in read only?

Try Workbook activities

Thanks, this is a good suggestion also. I managed to get it working the way I needed by using Excel Application Scope and ticking “Read Only” for the bot to read the file, and it seems to write to the file while open too (updates the contents when re-opened).

1 Like