Using LockServerFile Method on Sharepoint Online

TsukubaGT1 1 Reputation point

My company is in the process of migrating from classic SP to Sharepoint Online, and I manage several macro-enabled Excel projects. Most of these projects open other common Excel files, and part of the process for locking files for editing is to check if another user has the file open by using the LockServerFile method. This works because the classic Sharepoint site opens every file as read-only by default (the yellow ribbon with the 'Edit Workbook' button appears upon opening). However, the new Sharepoint Online sites open files in edit mode, and calls to LockServerFile result in an error. I did not create these projects, and was told that attempts to use Check In/Check Out in the past to try to restrict users to editing one at a time had caused issues in the past, so I am trying to avoid that.

My questions are the following:

1) Is there some kind of setting within Sharepoint that can make all files (or at least Excel files) open as read-only by default, while still allowing users the option to change to edit mode?

2) Assuming the answer to my first question is yes, is LockServerFile still compatible with SPO?

3) If I can't use LockServerFile, is there any alternative outside of Check In/Check Out, or is that my only alternative?

Thank you

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,002 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 43,176 Reputation points Microsoft Vendor


    1.Please go to Library settings -> Versioning Settings -> Set Require Check Out as Yes. Then when users open files, files show Viewing by default.


    2.Excel macro is not supported in the browser.

    3.From SharePoint side, besides check in and check out feature, there is an OOTB way to achieve this. I recommend you use check in and check out feature to keep others from making changes when you are making changes to a file.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.