municool
municool

Reputation: 48

Creating a VSTO Add in for multible applications

Is it possible to create an VSTO add in for multible office applications?

Can I outsource the functions i want to have for every application and then create an Add-in for every application? If yes, is there a better way to achieve this?

Upvotes: 3

Views: 188

Answers (4)

Olga Lavrienko
Olga Lavrienko

Reputation: 1

VSTO itself doesn't provide such an option. If you want to get single project for all application you can use shim add-in. That makes possible to run add-in in all applications from the same dll. The only issue -- your code need to handle what application started to call it to run separate logic or to call specific office API functions.

Upvotes: 0

Eugene Astafiev
Eugene Astafiev

Reputation: 49455

VSTO doesn't support creating multi-host add-ins. You need to create separate projects for each host and use a class library for the shared code base.

Note, Add-in Express allows creating multi-host COM add-ins. So, a single add-in project can be run in multiple hosts. It comes from the IDTExtensibility2 interface. I don't know why VSTO creators didn't provide such feature to developers.

Upvotes: 0

Gertsen
Gertsen

Reputation: 1113

I recommend making a solution with an add-in project for each Office application.

Then add a class library project to the solution and reference that from each of the add-on projects.

That way you can centralize code used in all add-ins.

If you need to interact with the active application or document, you can detect the type of the calling object and typecast it to the relevant application/document type.

Upvotes: 4

PhillipH
PhillipH

Reputation: 6222

Yes - you can just put your common functions into a shared DLL, just like any other application. Since each VSTO project targets a different application structure and potentially UI paradigm, I'd recommend having different VSTO projects in a single solution, and a shared assembly holding the common code.

Upvotes: 4

Related Questions