none
Read-Only spreadsheet issue after FileConverter conversion RRS feed

  • Question

  • Hello,

    I am working on a solution to support some custom document formats in office (word, excel and powerpoint). The current approach is based on some COM+ file converters as it is explained here. While in Word and Powerpoint the documents are converted properly, in Excel the converted document is opened as read-only. If the user wants to modify it, he has use the "save as" option.

    I am pretty sure that the converted document has no special property saying that it is read-only (I can open it alone and it is writeable). 

    It is like a missbehaviour that only happens when the document is open using file converters interface.

    Any workaround, fully working example with Excel or some registry trick to avoid this?

    Thank you!

    P.D.: One possible solution could be the document life cycle events but I would like to avoid it.



    Tuesday, September 9, 2014 3:13 PM

Answers

  • Hello luis.sanchez.sanchez,

    I tried to look into your code but could not find a solution / workaround.

    Because of its complexity your question falls into the paid support category which requires a more in-depth level of support.  If the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged. Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Thanks!!

    Tuesday, October 7, 2014 8:24 PM

All replies

  • Hello Luis Sanchez,

    You can fix the issue clearing the read only flag programmatically. The SetAttributes method of the System.IO.File class sets the specified FileAttributes of the file on the specified path. For example:

    FileAttributes attrs = File.GetAttributes(fileName);
    File.SetAttributes(fileName, attrs | FileAttributes.ReadOnly);

    Tuesday, September 9, 2014 7:46 PM
  • Thank you Eugene but it doesn't work. It is not related with file permissions.

    When I open with Excel my custom format document, this method is called in the COM+ component

    public void HrImport(string bstrSourcePath, string bstrDestPath,  IConverterApplicationPreferences pcap, out IConverterPreferences ppcp, IConverterUICallback pcuic)

    The bstrDestPath points to a file that contains the traslation from my custom format to an Excel document. After that, Excel displays it as read only. 

    If I open directly the file (bstrDestPath) with Excel, it works and I can edit it.

    Wednesday, September 10, 2014 9:11 AM
  • Where does the HrImport method come from?

    How is the issue related to VSTO?

    Wednesday, September 10, 2014 12:17 PM
  • In this link http://msdn.microsoft.com/en-us/library/dd300649(v=office.12).aspx you can find how external file converters works. The HrImport method is called when you open a document (previously you have to register your custom extension and the file converter), the office app gives the source path and the target path where the file converter should place the converted document.

    I don't know what it is. Maybe just an Excel bug with external file converters. This behaviour only happens with Excel.


    Wednesday, September 10, 2014 3:20 PM
  • Hi Luis,

    If the workbook is read-only, most probably it is in used by other processes.

    Suppose the process was not clear after converting.

    Have you checked the processes in Task manager? Is there a background Excel process existing?

    If so, you could check the code. It would be better to use "try-catch-finally" statement and release resouce in "finally". Also, you could try Marshal.ReleaseComObject Method.

    Regards,

    George.


    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, September 16, 2014 8:48 AM
    Moderator
  • Thank you George.

    I have checked that the file is not being used by any other processes using ProcessExplorer. No process has any file handler related with the file that is finally open after the conversion.  I thought it could be in used by the COM+ file converter, but it is not the case.

    I have also debugged the fileconverter (a COM+ Service Component). When a custom format document is converted, Excel gives you the source file path and the destination file path. In the fileconverter, I copy the document (an xlsx one) to the given destination file path. This is the file that it is open as read-only by Excel using the flow: Excel->FileConverter->Excel but If i open directly the converted document (It is in  %USERPROFILE%\AppData\Local\Temp) I get a writable spreadsheet.

    I think there must be something wrong with Excel-FileConverter-Excel flow.  Maybe, Excel does not fully accept the custom format extension and that explains why it is open as read-only. 

    I use the same fileconverter COM+ service component to convert custom Word and Powerpoint extensions (almost the same code is executed) but the behaviour is different. Word and Powerpoint document are writable but Excel is read-only.


    Tuesday, September 16, 2014 11:26 AM
  • Hi Luis,

    Thanks for your feedback.

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards,

    George.


    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.

    Wednesday, September 17, 2014 3:26 AM
    Moderator
  • Thank you George.

    I attach a sample project base on this article http://blogs.msdn.com/b/speront/archive/2009/04/17/9553717.aspx

    This is the download link: sample project zip


    Monday, September 22, 2014 9:23 AM
  • Hello luis.sanchez.sanchez,

    I tried to look into your code but could not find a solution / workaround.

    Because of its complexity your question falls into the paid support category which requires a more in-depth level of support.  If the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged. Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Thanks!!

    Tuesday, October 7, 2014 8:24 PM