VBA Macro to Open Read Only Excel from SharePoint and Enable Edit Workbook

ak_254

New Member
Joined
Jan 9, 2018
Messages
10
Hi all,


I am currently in the process of trying to create a macro to run from my current workbook (file1) and be able to open an excel file from SharePoint (file2) to refresh and update using the data from (file1).


The only problem I am running into so far is when opening (file2) it is opened up as a "Read Only" requires the prompts message "Enable Editing" to be enabled before edits can be made to (file2)


I am looking for a way to be able to automatically click enable editing when opening (file2)

Below I have included the code I currently have running to open (file2) from (file1)



Workbooks.Open _
Filename:="C:\Desktop\Automation Project\In_Stock.xlsx", _
UpdateLinks:=3, ReadOnly:=True, Notify:=False


Any help is much appreciated.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi ak_254,

I know your query was posted long ago but I have found the solution to break the Read-Only and update the excel document via Macro:

If you add "ActiveWorkbook.LockServerFile" after opening the file code, then it removes the Read-only and updates the excel as normal.


Regards,
KDxcel

Hi all,


I am currently in the process of trying to create a macro to run from my current workbook (file1) and be able to open an excel file from SharePoint (file2) to refresh and update using the data from (file1).


The only problem I am running into so far is when opening (file2) it is opened up as a "Read Only" requires the prompts message "Enable Editing" to be enabled before edits can be made to (file2)


I am looking for a way to be able to automatically click enable editing when opening (file2)

Below I have included the code I currently have running to open (file2) from (file1)



Workbooks.Open _
Filename:="C:\Desktop\Automation Project\In_Stock.xlsx", _
UpdateLinks:=3, ReadOnly:=True, Notify:=False


Any help is much appreciated.
 
Upvote 0
Tried a lot of solutions, the only one that successfully worked for me was the adaptation of your link to the file:

From this (as you copy it via "Copy link" in SharePoint"):

VBA Code:
https://pmt.sharepoint.com/:x:/r/teams/ClearServiceRus/Teams%20Wiki%20Data/General/Book.xlsx?d=wc4cde03eae523df9a7082c18g4ege61b&csf=1&web=1&e=lnONME

To this (special attention to part) :
VBA Code:
 "/:x:/r"

VBA Code:
https://pmt.sharepoint.com/teams/ClearServiceRus/Teams%20Wiki%20Data/General/Book.xlsx

Code:

VBA Code:
    URL = "https://pmt.sharepoint.com/teams/ClearServiceRus/Teams%20Wiki%20Data/General/Book.xlsx"
    Set wb = Workbooks.Open(URL)
    Debug.Print wb.FullName
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top