Problem sending file to server when in OneDrive

When the Excel file is synchronized via OneDrive and is open in the Excel application, when you try to select the file, the message “The file is in use” appears and this is correct. However, when I drag and drop the file, no message appears, but when sending the file to the server, the file is not sent.

Is there any way to check if a file is being used by another process? To be able to display the message yourself.