question

BrenchleyDavidScott-3491 avatar image
0 Votes"
BrenchleyDavidScott-3491 asked MichaelHan-MSFT answered

Programmatically changing Excel file from SharePoint from read only to readwrite

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



office-sharepoint-server-development
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered BrenchleyDavidScott-3491 commented

Hi @BrenchleyDavidScott-3491

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TY
Michael .. I do not note any switches in the link to the file I am attempting to open.
I've previously attempted .LockServerFile both in the code opening the file and in the Workbook.open method of the file being opened, to no effect.

0 Votes 0 ·
MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered

Hi @BrenchleyDavidScott-3491

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

100414-image.png



image.png (18.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.