I am getting Runtime error 1004: cancheckout method failed near cancheckout and
Compile error: Method or data member not found in line
If Workbooks.CanCheckIn(ChkFile) = True Then
How do I resolve the issue?
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
Try changing ChkFile = "http://new1....com/Shared%20Documents/file.xlsm"
to ChkFile = "http://new1....com/Shared Documents/file.xlsm"
, i.e. replacing %20
for a space since the whole path is already within brackets