Write enable in Sharepiont with VBA

HeinzBrunner

New Member
Joined
Jul 6, 2018
Messages
1
Hi

I have a macro, which opens another Excel file from Sharepoint and writes data in it. To write-enable the file, I use "ActiveWorkbook.LockServerFile". This works fine with Office 2016.

Now we are changing gradually to Office 365, so some computers are equipped with with Office 2016 and some with Office 365. In Office 365, ActiveWorkbook.LokServerFile gives a run time error 1004.

When I omit this line and instead include in the file I am opening the Macro:

Private Sub Workook_Open()
ActiveWorkbook.LockServerFile
End Sub

it works in Offfice 365, but office 2016 doesn't enable editing and the main macro can't write the data.

I need a solution, which works with both, Office 2016 and 365. Can someone help?

Thanks
Heinz
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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