I ried this code to print data from my project to Excel file if the File is open . but didn't success
Dim exl As New Excel.Application Dim exlWorkSheet As Excel.Worksheet Try Dim fs As IO.FileStream = File.Open("C:\ta1.xlsx", FileMode.Open) fs.Dispose() MsgBox("Not open") Catch ex As IOException exl.Workbooks.Add("C:\ta1.xlsx") exlWorkSheet = exl.Worksheets("sheet") exlWorkSheet.Cells(2, 6).Value = "Open" End Try