If Workbooks.CanCheckOut(xlFile) = True Then
Workbooks.CheckOut xlFile
'...code here does stuff
'Save Workbook
ActiveWorkbook.Save
'Check In Workbook back to sharepoint
ActiveWorkbook.CheckIn
Else
MsgBox ("The file is currently in use. You are unable to check out this document at this time. Please try again later"), vbInformation, "File already checked out"
End If
End With
Exit Sub