Solved

OLE Automation

Posted on 1997-04-29
4
404 Views
Last Modified: 2010-04-04
I've written an application that calls Excel 95 as a "scratchpad calculator."  That is, I have a database where one field contains a (usually) properly formatted Excel formula, I pass that formula to Excel via the (via the clipboard, to be able to enter formulas between 256 and 1024 characters in length) and then read the cell back to get the result.  I then store the result into another field in the table.  For a simple example:

Clipboard.asText := '=AVERAGE(1,2,3)'
ExcelObject.Range('A1:A1').Select;
ExcelObject.Activesheet.Paste;
TheResult := ExcelObject.Range('A1:A1').value;

This works fine.  As I loop through the database, however, the time per execution increases: what starts out at about 3 seconds per 10 calls gradually increases to about 10-15 seconds per 10 calls.  Sooner or later, I get an OLE error saying "The remote procedure call failed" in the result fields of several records, and then it just quits.

What's going on here?  Am I somehow leaking resources?  How can I resolve this so that execution keeps up its speed and doesn't punk out?

Later on in the app, I open Word to do a mail-merge based on the resulting data, and this starts off working fine also.  It uses ODBC to get to the Interbase table that's holding the data.  After merges of about 35 small-to-middling document templates -- all of which I close when finished -- I got an OLE error message "The server threw an exception" and it hung up, forcing me to re-boot.  (I'll refrain from describing what it was I wanted to throw.)  In doing so, I discovered that Word was still open on the problematic file, but inivisible, so I couldn't get to see what was going on.

Any help with either/both of these problems would be greatly appreciated.

TIA.

0
Comment
Question by:nrosenblatt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:nrosenblatt
ID: 1335778
Edited text of question
0
 
LVL 1

Expert Comment

by:Heapster
ID: 1335779
Ole is a mysterious and dangerous beastie - whilst i dont know the answers to your questions, i do know for a fact that OLE does not work properly in Delphi applications.  If you are only using excel 95 to do a bit of autocalcing, then you could use Formula 1 spreadsheet, which does pretty much everything excel does, and you can get a handle on it.  Same solution with word really - i would use WPTools from 'http://members.aol.com/jziersch/index.html' which has mail merging.
0
 

Accepted Solution

by:
msnell earned 100 total points
ID: 1335780
There are several components that you coulld use instead of
Excel

Go to the Delphi Super Site (sunsite.icm.edu.pl) and choose
Search ..

TFormulaCompiler sounds like one of the better ones:
http://www.uniyar.ac.ru/~vlads
0
 

Author Comment

by:nrosenblatt
ID: 1335781
Dear msnell-

While a workaround is almost as good as a solution, I'm not sure that in this case the workaround is fully useful.  Truly, the example I gave is simple-minded, but in fact, the real-life usage will involve using many of Excel's more exotic functions that I'd be hard-pressed to believe are reliably duplicated in a non-major-vendor's offering.

I'll give it a look, though, and thanks for your response.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question