I have this code that checks to make sure the workbook is not open/in use. How would I modify it to try again in 5 seconds and after 3 tries then send the MsgBox?
If wBook.ReadOnly = True Then
MsgBox "Database is in use. Please try after sometimes.", vbookonly + vbCritical, "error"
Exit Sub
End If
Something like this?
For i = 1 To 3
If ActiveWorkbook.ReadOnly = True Then
Application.Wait Second(Now()) + 5
Else
ActiveWorkbook.Activate
MsgBox "write"
Exit Sub
End If
Next
If ActiveWorkbook.ReadOnly = True Then
MsgBox "Database is in use. Please try after sometimes.", vbookonly + vbCritical, "error"
Exit Sub
End If