Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the Active Workbook?

Tags:

excel

c#-4.0

vsto

I'm trying to get the Workbook in my application(VSTO) like this :

ExcelViewModel mb = new ViewModels.ExcelViewModel();
string NameBox = mb.Workbooks.First().Name;

So when Excel open, it already have the default workbook : Book1.xlsx i open for example a second workbook(example.xlsx) but my string NameBox return the "Book1". How can i get the active Workbook? for my example the "example.xlsx" one.

The ExcelViewModel just return me an ObservableCollection of all Workbooks.

Thank you.

like image 814
3logy Avatar asked Feb 04 '26 09:02

3logy


1 Answers

I found it :

Globals.ThisAddin.Application.ActiveWorkbook.Name
like image 123
3logy Avatar answered Feb 06 '26 08:02

3logy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!