none
Detect if excel workbook (openXML or Structured Storage) is a Shared Workbook outside of Office RRS feed

  • Question

  • Is there a way to examine an xls or xlsx file to determine if the workbook is shared?  I want to do this via a stand-alone app, not as part of an Office Plugin.

    I noticed that in the case of openXML, there is an element named <SharedDoc> in docProps\app.xml but in all cases I have looked at, this is always set to false.

    I have browsed the various xml files and also examined storages and streams for shared xls documents but could not find anything that looks relevant while comparing shared/non-shared examples.  I assume this information must be embedded in the files somewhere such that Excel can find out when the document is opened.

    Monday, May 4, 2015 2:23 PM

Answers

  • Hi Peter,

    As far as I know, for the ways to detect if excel workbook is shared or not, the workbook should be opened, for example, using open xml SDK also need to open the file, just by using different way, the file also occupied.

    Using the open xml way, I compared the shared and non-shared files, I found that the shared file adds some additional files, so you could check these additional parts.

    For excel object model, if you open the excel file with shared mode, we could check ActiveWorkbook.MultiUserEditing property.

    For app for office, I don’t find a way to accomplish that.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 5, 2015 3:44 AM
    Moderator

All replies

  • Hi Peter,

    As far as I know, for the ways to detect if excel workbook is shared or not, the workbook should be opened, for example, using open xml SDK also need to open the file, just by using different way, the file also occupied.

    Using the open xml way, I compared the shared and non-shared files, I found that the shared file adds some additional files, so you could check these additional parts.

    For excel object model, if you open the excel file with shared mode, we could check ActiveWorkbook.MultiUserEditing property.

    For app for office, I don’t find a way to accomplish that.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 5, 2015 3:44 AM
    Moderator
  • I looked at the openXML SDK.  The FileSharing property on the Workbook always comes back as null regardless of whether or not the workbook is shared so that seems of no value.  I could not see anything else in the Workbook or WorkbookPart or SpreadsheetDocument that looked like it defined the document as a shared documument.

    I will check the additonal xml information you highlighted.  I had seen something similar last week and thought I had found something useful - but the attribute in question that seemed to define sharing enabled did not go away after I removed sharing from the document so that appears to be no good as an indicator.  I think the element was <CustomWorkbookView> or similar in xl/workbook.xml.

    Tuesday, May 5, 2015 3:54 PM
  • Hi Peter,

    Base on my test, the value of SharedDoc is false too.

    You may consider to post it to the Office XML forum.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 7, 2015 2:45 AM
    Moderator
  • Looks like your earlier suggestion was correct - there are in fact additional xml files present for the shared case, and one of them is even named "userNames.xml" which is consistent with the Structured Storage case where the presence of a stream named "User Names" defines the file as Shared.

    Thanks for the tip!

    Pete

    Thursday, May 7, 2015 6:27 PM