Developing a VSTO add-in for EXCEL. I plan to work with the ClosedXML library. However, all the examples show the creation of a new file and work with it (with the obtained references to the book it has created). Is it possible to get a link to an already open book? What I try fails:

private void ThisWorkbook_Startup(object sender, System.EventArgs e) { var workbook = **?**; var ws = workbook.Worksheet(1); var rngHeaders = ws.Range("B3:F3"); rngHeaders.Style.Fill.BackgroundColor = XLColor.LightSalmon; } 

Options like this don't work:

 var workbook = ThisApplication.ThisWorkbook; 

And the second question - when creating a file with ClosedXML, is it possible not to save it, but simply open it through the EXCEL application?

    0