0

I've searched the internet for the answer to this and keep running into issues getting it to work.

I need to check if a file at the below location is open/locked, and then have the code wait 15 seconds and then try again. Right now if someone else has the file open a dialog box opens asking if I want to open read only, which I don't want. I tried using Application.DisplayAlerts = False to get the message not to appear but that didn't seem to work. So I have two main issues:

  1. Checking if the file is open and waiting to try again.
  2. Stop the dialog box from opening asking to open as read only.

Workbooks.Open filename:= _ "https://somecorporatewebsite/sites/TNKYWest/Engr/ASE%20Updates/Shared%20Documents/ASENW Updater.xlsx"

scsims
  • 17
  • 7
  • maybe this will help http://stackoverflow.com/questions/25668098/detect-if-sharepoint-file-is-open – Slai Aug 02 '16 at 12:45

1 Answers1

0
  1. Try something like this:

From MSDN site: https://msdn.microsoft.com/en-us/library/office/ff193284.aspx

Sub UseCanCheckOut(docCheckOut As String) 
Dim docCheckout
set docCheckout="File name to open"
' Determine if workbook can be checked out. 
If Workbooks.CanCheckOut(Filename:=docCheckOut) = True Then 
Workbooks.CheckOut (Filename:=docCheckOut) 
Else 

Found at the MSDN Website: https://msdn.microsoft.com/en-us/library/office/ff822851.aspx

Application.Wait(Now + TimeValue("0:00:10")) 
Workbooks.CheckOut (Filename:=docCheckOut) 'Try to check the file out again.
End If 

End Sub
  1. This part is covered in the

    IF workbooks.cancheckout(filename:=docCheckout)=true then workbooks.checkout ' method in part 1.