473,847 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Applicati on
Dim oBook As Excel.Workbook
Dim oBooks As Excel.Workbooks
Dim oSheets As Excel.Sheets
Dim oSheet As Excel.Worksheet

oExcel = CreateObject("E xcel.Applicatio n")

oBooks = oExcel.Workbook s

oBook =
oBooks.Open("C: \Inetpub\wwwroo t\PrePackOptimi zer\Data
Source\book2.xl s")

oExcel.AddIns.A dd("C:\Program Files\Microsoft

oExcel.DisplayA lerts = True

oExcel.Run("Mod ule1.SOLVER")

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

Dec 16 '05 #1
3 6997
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

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,

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("Sol ver.xla!Auto_Op en")

Once this was done my application started working as


Dec 16 '05 #4

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

Similar topics

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 fitting to the data. I have a VBA macro which runs the Solver, and am using self.xlapp = win32com.client.dynamic.Dispatch("Excel.Application") .. .. .. self.xlapp.run(macro)
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? In an application I would like to solve a model with 500 variables. Excel-Solver can do this but I want to do it all in code. any thoughts are appreciated! Josh
by: akantrowitz | last post by:
Can you replicate the Excel solver functionality from within Csharp? thks, ak
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
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 out after googling for the last 3 days. I have written a large python script which inside of it creates an Excel table, the name of this file and how many objects can change for each project i run.
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 from the database but I am not sure how do I put a command button and associate a macro with that using C#. Can anyone help me?? Thanks in advance. Senthil
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 Worksheets(1).Range("B9").Select
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 apps: MS Excel What I need to do: From a web page using javascript, I open a new Excel application and sheet, populate some information into it. After it is populated with some information, I need to run the "Solver..." option on the data in the...
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 excel I get the error Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005. System.UnauthorizedAccessException: Retrieving the COM class factory for
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.