1
votes

I want to run (open) Excel within a C# program and load a specific add-in simultaneously. Is this possible? The C# program should be a kind of launcher EXE, which opens an own specific Excel solution (Excel with a specific Addin (DLL), which is developed with VSTO). The Add-In (the ribbon there) starts from the scratch, so that all other build-in tabs are hidden. The Add-In should only be loaded, when Excel is launched by the launcher EXE.

I know that excel can for example be started with

 ProcessStartInfo startInfo = new ProcessStartInfo();
 startInfo.FileName = "EXCEL.EXE";
 Process.Start(startInfo);

But is there a possibility to say the new Excel process, which addin should be load?

2
Is your addin an .xlam or a .dll? - Michael Gunter
Ah. I don't think there is a way, then. The Excel command line only supports "/r" (useful for .xlam's) and "/a" (for Automation addins). - Michael Gunter

2 Answers

1
votes

I would check into using the interop from that version of Office.

Here is some information on the namespace, you should be able to get to the DLLs from the extension or they are located within your office folder. As far as running a specific plugin there may be something in the interop library that can helo with that but I'm not sure.

http://msdn.microsoft.com/en-us/library/ms262200(v=office.11).aspx

0
votes

You can achieve this by hacking registry. Before starting excel goto registry and set load behaiour of addins you want to appear at start to Load(3). After excel process is launched in your launcher reset those addins load behaviour to unload(0) so that when someone starts excel this addin will not appear. Your launcher code will look somewhat like this

// Code to change load behavior of addins to Load
   ProcessStartInfo startInfo = new ProcessStartInfo();
   startInfo.FileName = "EXCEL.EXE";
   Process.Start(startInfo);
// Code to change load behavior of addins to UnLoad