PDA

View Full Version : [SOLVED:] Not Working : Opening an Excel workbook from SharePoint in edit mode from a user form



anish.ms
04-24-2021, 09:22 PM
Hi Experts,

I am trying to open an Excel workbook in edit mode from my company's SharePoint site through a user form in Excel. This user form will be used by multiple users (as an excel add-in) for recording their daily activities. So basically I want to allow multiple users to open the excel workbook at same time and add entries using this user form. Following are the issues that I'm facing.


If a user opening it for the first time then it opens in read only mode.
And later on, only for the first user it is opened in edit mode for rest all the users it is in read only mode.

I tried the following by searching this issue on the internet, but nothing could resolve the issue-
I tried adding ActiveWorkbook.LockServerFile to the created object (returns an error)
The error I get is Run-time Error '1004' Method 'LockServerFile' of object' _Workbook' failed
I also tried opening it using : Workbooks.Open(ReadOnly:=False), also did not help



Sub UserForm_Initialize()
DBFile = "https://companydomain-my.sharepoint.com/personal/central_bkp_companydomain_com/Documents/Central%20BKP/Time%20Sheets/Time%20Sheet%20Database.xlsx"
Set DestnWB = Application.Workbooks.Open(Filename:=DBFile, Password:="XXXX", ReadOnly:=False)
'DestnWB.LockServerFile



Following is the message that the user gets on clicking Submit button which adds all the entries to the workbook and save the workbook
28358

Error on clicking "No"
28359

Thanks in Advance

anish.ms
04-27-2021, 07:20 PM
I think encryption of the file was the problem, which also disables the autosave option.
It seems to be working after removing the encryption.