Greetings All,

For a document which is checked out from a SharePoint workspace, is it possible to programmatically discard the document checkout from an add-in

The most reasonable API call would seem to be:

Word.ActiveDocument.CheckIn(false, ref comments, false)

But I have been unsuccessful with this call, which raises the error:

System.Runtime.InteropServices.COMException was unhandled
HelpLink="C:\\Program Files\\Microsoft Office\\Office12\\1033\\WDMAIN11.CHM#25573"
Message="The check out cannot be undone."
Source="Microsoft Word"
at Microsoft.Office.Interop.Word.DocumentClass.CheckIn(Boolean SaveChanges, Object& Comments, Boolean MakePublic)

While the message in the exception claims "The check out cannot be undone", from the Word UI, it is indeed possible to discard the check out, so the error is a bit misleading. Is there an API call to discard the check-in that I simply haven't found Or perhaps I'm doing something incorrectly with the call to CheckIn

Any leads would be appreciated.


Re: Visual Studio Tools for Office Possible to Programmatically Discard Checkout?


Ive done something like that from the object model (you must run on the SharePoint server, may be called from a WebService). This is a code fragment:

SPQuery Q = new SPQuery();
Q.Query = . . . // CAML
SPListItemCollection ItemPrincipal = MainLista.GetItems(Q);
foreach (SPListItem Item in ItemPrincipal)

if (Item.File.CheckOutStatus == SPFile.SPCheckOutStatus.LongTerm ||
Item.File.CheckOutStatus == SPFile.SPCheckOutStatus.LongTermOffline)


There might be something available at the WebService SharePoint API.