ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2003 + Solver + C# (https://www.excelbanter.com/excel-programming/284434-excel-2003-solver-c.html)

David

Excel 2003 + Solver + C#
 

Sorry for the cross post but I need an answer to this
ASAP and wasn't sure which newsgroup is the most relevant
since this problem covers a number of areas.

Problem:
How to automate Excel 2003 with C# and use the Excel
Solver add-in.

I've setup a spreadsheet that has a number of cells
within it that I must populate through automation, I then
have a macro that performs a Solver function on these
cells and produces an answer which I then must retrieve.

The spreadsheet, Solver and the macro all work fine when
opened independently not using automation with C#.

Further the cells are populated and the macro is called
no problem with automation.

The problem comes when the C# program calls the Excel
macro that calls the Solver function, I get the
infamous "Solver: An unexpected internal error occurred,
or available memory was exhausted." error message.

This happens every the time.

HOWEVER if I pause the C# program (with Excel visible)
just before calling the macro, open the Tools-Solver
dialogue and immediately close it without performing a
Solve, and then let the C# program perform the macro it
works fine.

So it looks like Solver may not be getting initialised
properly.

One thing to note, this works fine using VB6 and Excel +
Solver, we've only hit problems with .Net and Excel +
Solver.

Anyone with any ideas, anyone from the Office2003 + .Net
interop?

We'll have to rewrite this functionality using VB if we
cannot resolve this, bit of a backward step!

Many thanks

David




All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com