Can I use Microsoft.Office.Interop.Excel in a dll/xll

229 Views Asked by At

I am writing a ConsoleApp in C# to open and make some modifications to an Excel workbook, and I am using Microsoft.Office.Interop.Excel. It works quite well, but my goal is to write a dll/xll to do the job with a call from an excel macro. Can that be done, and if yes, how can I get an Excel.Workbook handle attached to the calling Excel process ?

I am rather new to this, so forgive me if I ask silly questions :-)

1

There are 1 best solutions below

0
tranquillity On

Yes, you can but writing an xll is an extremely complex process compared to calling Microsoft.Office.Interop.Excel from a console app.

To create an xll you need to implement all the relevant functions shown in the XLL SDK. After that, it is simple enough to get a pointer to the Excel.Application interface.