Hello there,
Preventing simultaneous execution of scripts in Excel Online can be challenging since Excel Online does not provide native locking or concurrency control mechanisms. However, you can employ some workarounds to minimize the likelihood of simultaneous script execution and potential conflicts. Here are a few options:
User notification and collaboration: If multiple users are accessing the same Excel Online workbook, you can implement a communication mechanism to notify other users when a script is being executed. This can be done through chat, comments, or a shared document to ensure users are aware and avoid simultaneous execution.
Shared lock mechanism: Implement a shared lock mechanism using an external data source or file. For example, you could create a separate file in OneDrive or SharePoint that acts as a lock file. Before executing a script, a user checks if the lock file exists or is currently held. If it is, the user waits until the lock is released. Once the script completes, the lock is released for other users to access.
Script scheduling: If the script execution is not time-sensitive, consider implementing a scheduling system. Users can submit their scripts to a queue, and a central service or script can pick up and execute them one at a time. This ensures sequential execution and minimizes conflicts.
Splitting workbooks: If possible, split the workbook into multiple smaller workbooks, each with its own set of scripts. This approach limits the chances of conflicts arising from simultaneous execution in the same workbook.
I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.