title: Checkout and checkin sharepoint file
body: <p>I am getting Runtime error 1004: cancheckout method failed near cancheckout and</p>
  
  <p>Compile error: Method or data member not found in line</p>
  
  <pre><code>If Workbooks.CanCheckIn(ChkFile) = True Then
  </code></pre>
  
  <p>How do I resolve the issue?</p>
  
  <pre><code>Sub ToCheck()
      Dim xlApp As Excel.Application
      Dim wb As Workbook
      Dim ChkFile As String
      ChkFile = "http://new1....com/Shared%20Documents/file.xlsm"
  
      If Workbooks.CanCheckOut(ChkFile) = True Then 'getting error here
          Workbooks.CheckOut ChkFile
  
          Set xlApp = New Excel.Application
          xlApp.Visible = True
  
          Set wb = xlApp.Workbooks.Open(ChkFile, , False)
      End If
  
      ThisWorkbook.Activate
      Application.Run ("'file.xlsm'!Macro1")
  
      ThisWorkbook.Save
  
      Workbooks(ChkFile).Activate
  
      If Workbooks.CanCheckIn(ChkFile) = True Then 'Getting error here
          Workbooks(ChkFile).CheckIn
      End If
  End Sub
  </code></pre>