This project has moved and is read-only. For the latest updates, please go here.

How to get the name of the current workbook / worksheet

Dec 4, 2013 at 7:25 AM
Edited Dec 4, 2013 at 8:33 PM
From within Excel, with a worksheet already displayed, how does one get the current XLWorkbook instance?

I don't want to open it with new XLWorkbook as it is already open. I would expect a static method along the lines of "XLWorkbook.Current()" but I can't find such a thing.



PS. Let me add - this was a silly question. I was in the middle of an ADX-Addin thought and I should have gone for the coffee not the keyboard. R
Dec 4, 2013 at 2:10 PM
XLWorkbook wb = new XLWorkbook(fileLocation);  // open an existing workbook
XLWorksheet ws = wb.Worksheet(1);   // get first worksheet contained by this workbook
XLWorkbook sameWb = ws.Workbook;   // get reference to the workbook that contains this worksheet
Marked as answer by robvon on 12/4/2013 at 12:31 PM