Programmatically changing Excel file from SharePoint from read only to readwrite

Brenchley, David Scott 1 Reputation point
2021-05-26T23:23:57.08+00:00

Prior to my corp upgrading to Office 365 I had an Excel VBA macro that successfully would open and modify an Excel file off a SharePoint server.
Since the upgrade this file is flagged read only when opened.
I wish to be able to update the file with zero user interaction.
I've attempted various solutions offered on the web to no avail.
I've considered utilizing the API FindWindow function to drill down to the edit button and programmatically push it.
Unfortunately SharePoint seems to append the Window caption with the last modified date of the file.

  1. Is there an easier way to address my issue.
  2. If using the API call is the necessary course, how can I identify the window I'm seeking if the caption is changing.

THANKS for any recommendations

Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MichaelHan-MSFT 18,136 Reputation points
    2021-05-27T02:17:03.573+00:00

    Hi @Brenchley, David Scott

    Please try to use the filepath like the below: https://tenant.sharepoint.com/sites/test/Shared%20Documents/file.xlsx. Read this post for details: https://stackoverflow.com/questions/51029214/opening-excel-file-from-sharepoint-as-read-write

    Besides, you could try to use ActiveWorkbook.LockServerFile in your code to enable edit: https://stackoverflow.com/questions/45163549/excel-2016-sharepoint-file-still-opens-as-readonly/45171431#45171431


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.


  2. MichaelHan-MSFT 18,136 Reputation points
    2021-05-28T01:28:53.557+00:00

    Hi @Brenchley, David Scott

    In SharePoint library settings -> Advanced settings, You could try to change to Open Documents in Client Applications by Default.

    100414-image.png

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.