Search code examples
c#exceloffice-interop

Open Excel programmatically in "Read Shared" mode


My program uses office interop by starting an Excel application (process) and opening an existing workbook. I must be absolutely certain that all changes written to the workbook by the program can be saved, i.e. something similar to opening a System.IO.File with FileShare.Read or FileShare.None If file is already opened for writing, my program must be able to detect that. Anyone knows how to do?


Solution

  • You may check readonly or isDirty.

    With a sample program this may be checked quickly by opening the same workbook in Excel at the same time.