473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Excel Solver macro from VB.NET

I'm trying to run a Excel macro, which uses SOLVER.XLA Add-In, in
VB.NET application. When the macro is executed I get the following
error message

"Solver: An unexpected internal error occured, or
available memeory was exhausted"

Any suggestions whats causing this error and how to debug it???

Also, I get the following exception message when executing all the
macros from the excel sheet

"Exception from HRESULT: 0x800xxxxx"

I'm not sure about the source of this either.

Can anyone pls help me with these errors?? :)

My code for reference:

Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oBooks As Excel.Workbooks
Dim oSheets As Excel.Sheets
Dim oSheet As Excel.Worksheet
Try

oExcel = CreateObject("Excel.Application")

oBooks = oExcel.Workbooks

oBook =
oBooks.Open("C:\Inetpub\wwwroot\PrePackOptimizer\D ata
Source\book2.xls")

oExcel.AddIns.Add("C:\Program Files\Microsoft
Office\OFFICE11\Library\SOLVER\SOLVER.XLA")

oExcel.DisplayAlerts = True

oExcel.Run("Module1.SOLVER")

P.s.: The macro and the SOLVER runs perfectly when run from the EXCEL
file.

Dec 16 '05 #1
3 6961
this errors seems of memory leaks. when u run the managed code it runs
in its app domain. so the meory alloted by CLR is not enough to run the
code. if is there any way you can process the excel file in a divided
groups of data than you may not get error.

this could be one of the reason.

Dec 16 '05 #2
Mr.Doubt,

Are you sure that the methode were the code is running in is not goin enless
recursive (repeated).

That is hard to debug, because the debugger does not show that standard.

However that is mostly the reason for going out of memory.

Just a thought,

Cor
Dec 16 '05 #3
Thanx Lucky,

I've found the reason for the error, thanx to
http://www.officehelp.in/ It seems the Solver.XLA needs to be
explicitly opened before it can be used. This is done automatically
when we open the excel manually, but when we use objects, we have to
open it using the following command

oExcel.Run("Solver.xla!Auto_Open")

Once this was done my application started working as
expected...

Regards,
Dinesh

Dec 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Aaron | last post by:
I am trying to write a Python script file which analyses data in an iterative manner. During each iteration, I wish to utilise the Solver function in Excel to perform some constrained, non-linear...
0
by: Josh Golden | last post by:
has anyone every used the solver add-in for Excel? it allows you to solve linear and non-linear problems given certain conditions. I was wondering if something like this exists already in .NET? ...
0
by: akantrowitz | last post by:
Can you replicate the Excel solver functionality from within Csharp? thks, ak
2
by: tristan.chaplin | last post by:
Is it possible to use the Excel Equation Solver in an Access Database, ie call it from vba code? Thanks, Tristan
4
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
7
by: Holger Fitschen | last post by:
Hi to all, I want to use the Excel solver in a VB.Net project. The macro Sub Makro1Solver() Application.Run "Solver.xla!Auto_Open" SolverReset Worksheets(1).Select...
3
by: akristensen | last post by:
I am new to this site, so be patient if I do not ask the question correctly. Current Target Platform: Browser: MS IE, script language: Javascript (will use VBScript, but JS is preferred), External...
8
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a web site that automates excel. This site runs in server 2003. iis 6.0 office 2003 installed I moved this app to server 2008 iis 7.0 office 2003 installed Now when I try to automate...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.