Forum Discussion

BartH_NL's avatar
BartH_NL
Copper Contributor
Sep 06, 2022

Excel disable Read-Only from SharePoint with VBA

Hello Group,

We have a lot of Excel files that are saved with "read-Only recommended".

 

I would like to open files with VBA and also capture the click on "Edit Anyway" in code.

 

I have this code:

 

 

        Dim exApp As Excel.Application
        Dim wb As Excel.Workbook
        Set exApp = Excel.Application
        DoEvents
        exApp.Visible = True
'        Set wb = App.Workbooks.Open(Filename:=sfilename, UpdateLinks:=False, ReadOnly:=False, IgnoreReadOnlyRecommended:=true)
        Set wb = exApp.Workbooks.Open(Filename:=sfilename, ReadOnly:=False)
        DoEvents
        If ActiveWorkbook.AutoSaveOn = True Then ActiveWorkbook.AutoSaveOn = False
        DoEvents

 

 

When I open the file from SharePoint, there is no Read-Only active:

When I open it with the VBA code, Read-Only is activated,

although I have ReadOnly:=False in my Workbooks.Open statement.

How can I make this behave the way I want (so the file is opened in Excel without Read-Only restriction, same as when "Edit Anyway" would have been clicked).
Grtz, Bart

Resources