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"

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.