How to track my Excel 2007 appliction is open.
Posted on 2013-05-13
Hi, I am running vb.net application and open the excel file. Data are updated accordingly from vb.net to excel. I am managed this part.
I did use this function code to track my excel is open or not :-
Private Function TestEXCEL() as Boolean
dim fs as filestream
fs = File.Open(xlpath, FileMode.Open, FileAccess.Read, FileShare.None)
TestEXCEL = False
Catch ex as Exception
TestEXCEL = True
While after i do force close my excel file, my code try to reopen the file by coding i do face the error message as follows at this line
xlApp = New Excel.Application
xlworkbook = xlApp.Workbooks.Open(xlpath) <-- Error pointed over here
Error message : COMException was unhandled
Excel cannnot open the file 'Tri_data.xlsx' because teh file format or file extension in not valid. Verif that the file has not been corrupted and that the file extension matches the format of the file.