Click here to Skip to main content
14,773,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem that I have been working on for several weeks, exhausting all resources I have available.

I have a macro in the workbook that I am working in. The macro checks out a different spreadsheet (that I will want to make changes to) and then should check it back in. When I run the macro, it checks out the file and opens it. It then proceeds to the checkin subroutine, but fails with the message run-time error 1004 "Method 'CheckIn' of object '_Workbook' failed. I tried fully qualifying the checkin, but have the same results. I am including the code from the macro below.
Any assistance would be greatly appreciated, as I am totally stumped!
Option Base 1
Public wb0 As Workbook
Public xlFile0 As String
Public FileName0 As String
Sub Automation_Vetting_Process()
 xlFile0 = "http:// ..." 'Actual SharePoint URL
 CheckoutFile (xlFile0)
 FileName0 = wb0.Name
 CheckinFile (FileName0)
End Sub
Sub CheckoutFile(FileName As String)
' Determine if workbook can be checked out
 If Application.Workbooks.CanCheckOut(xlFile0) Then
  Application.Workbooks.CheckOut xlFile0
  Set wb0 = Application.Workbooks.Open(xlFile0)
  MsgBox wb0.Name & " is checked out to you."
  MsgBox "You are unable to checkout the at this time."
 End If
End Sub
Sub CheckinFile(FileName As String)
' Determine if workbook can be checked in
 If Application.Workbooks(FileName).CanCheckIn = True Then
  Application.Workbooks(FileName).CheckIn SaveChanges:=True, Comments:="", MakePublic:=False
  MsgBox FileName & " was checked in."
  MsgBox "You are unable to checkin the " & FileName & " spreadsheet at this time."
 End If
End Sub
Updated 27-Jun-11 6:43am

1 solution

I apologize for the incorrect title of this post. It should have been "Cannot programatically checkin Excel workbook to Sharepoint.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900