Piya27 4 Junior Poster

Hi All,

I am developing an Excel Add-in using Visual Studio Tools for Office using C#.
However, the problem is that i want to use the SOLVER add-in that is available in Excel in my code.
I cannot find any way or documentation anywhere for doing the same.

However i tried some code

//namespaces used
using VBIDE = Microsoft.Vbe.Interop;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;


//path where solver add-in is by-default installed
string solverPath = @"c:\program files\microsoft office\OFFICE14\library\SOLVER\SOLVER.XLAM";

//running Solver add-in
workbook.Application.Run("SOLVER.Auto_open",
      Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
      Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
      Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
      Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
      Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
      Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

but whenever i add reference to
Microsoft Visual Basic for Applications Extensibility 5.3
for Microsoft.Vbe.Interop;
I get some error regarding Assembly.

Moreover, If I use "workbook.Application.Run("SOLVER.Auto_open", .."
still I get error Saying "Cannot run the application".

I have searched everywhere but could not find any proper method or functionality to use solver in C#.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.