I have the following script to access an excel file from office365 Sharepoint.
dim objApp2 As Excel.Application
dim objBook2 As Excel._Workbook
dim objBooks2 As Excel.Workbooks
dim objSheets2 As Excel.Sheets
dim objSheet2 As Excel._Worksheet
link="sharepointlink"
objApp2 = New Excel.Application()
objBooks2 = objApp2.Workbooks
objBook2 = objBooks2.Open(link, [ReadOnly]:=False)
objSheets2 = objBook2.Worksheets
ws2 = objSheets2("Data")
Dim valoare As Integer
valoare = Int(ws2.Range("a1").Value)
ws2.Range("a1").Value = valoare + 1
objBook2.SaveAs()
objBook2.Close(False)
I have a problem: If someone accesses my link and opens the file, either on Sharepoint or opened locally, I get an error when trying to close the object or save the file.
How can I check if the file is opened by someone when I try to save, or is there another way to access the file?