Reputation: 1573
I am looking for a way I can automate an Excel VSTO Document level solution, to be called from an external application, similar to the VBA approach like "xlApp.Run("WorkBook", "MacroName") which we use to auto mate VBA solutions. As this will be a document level solution, Remoting or Webservices are not options. I am using VSTO 2010 and Framework 4 targeting Excel 2007 and 2010 versions.
Say, I have a Document Level Solution with a workbook named "TestBook" which contains a VSTO based class "MyClass" with a static function "GetData(string connection)" I am looking for a way to make a call to GetData function, from an external application. The solution itself will be loaded into excel by the external application too using Application.Workbooks.Open method.
To summarize: I am trying to find a way to get a reference to an object (ideally) and make a call to a function from a Document level solution after loading it. I am trying both ways like (External App)->(Addin)->(Document level object) but the route (External App)->(Document level Object) would be ideal.
Any pointers would be greatly appreciated.
Upvotes: 1
Views: 1844
Reputation: 70369
I suspect you need to go about this a bit differently...
The call a method the way you want you might a to resort to something called a "COM Automation AddIn" and implement a UDF this way.
You can then just place the call to your method as a formula inside any sell of that workBook - Excel eveluates that formula by calling your implementation. You can even tell Excel to reevaluate it.
Another option might be to build the functionality as a so-called RTD-server which is referenced in your workbook...
For some information see these links:
Upvotes: 1