none
How to overload SharePoint FileCheckIn operation in VSTO RRS feed

  • Question

  • Can anyone overload the SharePoint FileCheckIn operation using VSTO? I think it may have been forgotten (and a number of other operations)

    In my Ribbon XML I add the following three commands:

    <commands>
      <command idMso="FileCheckIn" onAction="FileCheckIn_Click"/>
      <command idMso="FileCheckOut" onAction="FileCheckOut_Click"/>
      <command idMso="FileCheckOutDiscard" onAction="FileCheckOutDiscard_Click"/>
    </commands>

    With the corresponding C# callbacks:

        public void FileCheckIn_Click(Office.IRibbonControl control, ref bool cancelDefault)
        { cancelDefault = false; /*Does not work*/ }
    
        public void FileCheckOut_Click(Office.IRibbonControl control, ref bool cancelDefault)
        { cancelDefault = false; /* Works! */ }
    
        public void FileCheckOutDiscard_Click(Office.IRibbonControl control, ref bool cancelDefault)
        { cancelDefault = false; /*Does not work*/ }

    Interestingly, FileCheckOut works fine, but FileCheckIn and FileCheckOutDiscard do not. Strangely, I had more success in VBA:

    Public Sub FileCheckIn()
        MsgBox "I work!"
    End Sub
    Public Sub FileCheckOut()
        MsgBox "I work!"
    End Sub
    Public Sub FileCheckOutDiscard()
        MsgBox "I don't.."
    End Sub

    Hopefully I've made a mistake somewhere along the way. Help appreciated. As far as I can see this functionality has been broken in Office 2007 and Office 2010. I haven't tested Office 2013 yet.

    Tuesday, November 27, 2012 5:52 AM

All replies

  • how do you invoke those commands from UI? Could you show us screenshot of that?
    Tuesday, November 27, 2012 7:43 AM
  • Hi Matthew,

    Thanks for posting in the MSDN forum.

    I will involve some experts into your issue to see whether they can help you. There might be some time delay, appreciate for your patience.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, November 28, 2012 7:36 AM
    Moderator
  • Thanks for the reply.

    Sorry, I'd like to post screenshots, but I get an error when I press Submit.

    "Body text cannot contain images or links until we are able to verify your account."

    I'm pretty sure it verified me before I created this post..

    Friday, November 30, 2012 8:22 AM
  • Thanks, that would be greatly appreciated.

    I've been using dodgy work arounds for the past few years. It would be great to get a definitive answer.

    Friday, November 30, 2012 8:24 AM
  • try to post links to images that are not really links, add spaces or something like that
    Friday, November 30, 2012 9:28 AM
  • try to post links to images that are not really links, add spaces or something like that

    Sorry, it's not that easy for me to do at the moment.

    It's pretty straight forward though. So i'll describe the steps:

    • Begin by opening a document from Microsoft SharePoint (any version)
    • Go to the 'File/Backstage View' in Word 2010 or Word 2013
    • Select the 'Info' tab
    • You will see 'Check Out' or 'Check In' buttons
    • Pressing either of these buttons should invoke the commands that I refer to
    Wednesday, December 5, 2012 12:37 AM
  • i can confirm your findings, in add-in command overwrite works if you place those buttons on ribbon, but in standard File location only FileCheckOut works. No idea how to fix it.
    Thursday, December 6, 2012 7:33 AM
  • I've done some testing in Office 2013. Even worse, I'm afraid:

    • None of the C# callbacks fire when a CheckIn/CheckOut/Discard is performed in the UI
    • Only the FileCheckIn VBA method works
    • Interestingly, the following line of code causes the CheckIn C# callback to fire
    this.Application.CommandBars.ExecuteMso("FileCheckIn");

    I guess it's possible that the UI/Backstage changes in Office 2013 changed the names of the VBA routines.

    Friday, December 7, 2012 5:51 AM
  • i can confirm your findings, in add-in command overwrite works if you place those buttons on ribbon, but in standard File location only FileCheckOut works. No idea how to fix it.
    Thanks. Hopefully Tom has access to people inside Microsoft that may be able to assist.
    Friday, December 7, 2012 5:53 AM
  • Hello Matthew,

    I tested the issue using Ribbon Extensibility and Backstage customization as well. However, the callbacks for FileCheckIn and FileCheckOut doesn't work with C# interop.

    There are certain items in backstage for which the customization cannot be done using .NET. It seems that FileCheckIn and FileCheckOut are among those.

    I don't see any way to customize the FileCheckIn and FileCheckOut options in backstage.

    Thanks,

    Sreerenj G Nair

    Friday, January 4, 2013 12:43 AM
  • Thanks for your reply Sreerenj

    Can you explain why this isn't possible?

    Was it forgotten by the SharePoint/Office teams?

    Will it be possible in the future?

    Tuesday, January 22, 2013 10:22 AM
  • I'd like to see a fix for this as well.  Is this simply a documentation bug?  Is there a different idMso that will actually work to intercept the "Save To SharePoint" button (as it's referred to in Excel 2010)?

    Matthew, if you ever found a good workaround, I'd be curious to know.  I've also seen your question on StackExchange on the same issue.

    Thanks, Eric

    Saturday, December 7, 2013 12:43 AM