How to check whether excel file is already opened with C#

Excel.Application oExcelApp;
using Excel = Microsoft.Office.Interop.Excel;
....
....

Excel.Workbook xlwkbook = (Excel.Workbook)System.Runtime.InteropServices.Marshal.BindToMoniker(@"C:\temp\book1.xlsx");

//True : already opened by human. False : not opened by human
bool isOpened = xlwkbook.Application.Windows["book1.xlsx"].Visible;

Trace.WriteLine(isVis);

댓글

이 블로그의 인기 게시물

Oracle NLS_DATE_FORMAT 변경

Stop console process using Ctrl+C.

Alternative to IValueConvert, QuickConverter