Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel and C++ interaction. How?

Status
Not open for further replies.

niceview

Technical User
Jul 23, 2001
4
US
This is concerning the use of Excel as the front-end for a program written in C++. The input and output is done in Excel, but the processing is done in C++.

Say that we have to multiply 'a' and 'b', available in cells A1 and B1 of Excel, and we want the product to be displayed in cell C1 of Excel too, but the product has to be calculated with a C++ program. How do I do it?

Do I have to work

1) exclusively in Excel,
2) exclusively in C++ or
3) part in C++ and part in Excel?

Do I need to store the intermediate results in a file or, otherwise, how do I get the cells I need (A1 and B1 in the example above) from C++?

Any guidance in this area will be very much appreciated.

I'd like to know where to start.
 
To be honest, this might be easiest to do in VBA through Excel. I guess it really depends on what you're trying to do with the numbers, though.
 
You can use COM. Is a powerfull technology. John Fill
1c.bmp


ivfmd@mail.md
 
The example described was a simple one. Actually, we have to take a matrix of, say, 500x5, do some operations with them and later return another matrix of 500x3. The code has already been developed in C++.

Does the code in C++ have to incorporate any DLL?

Is it necessary to write any code in VB in Excel?

Thanks,

NV
 
The answer is "Automation".Micro$oft has provided type libraries for its major applications specially Office suite to interact with external applications.The key dll for Excel is msexcel9.dll(For office 2000).Your should first study enough about COM and Automation.Then become familiar with Excel's object hierarchy.Then you will be able to make the interaction. Once I wrote a small app that gathered info from user in the application and made a chart using Excel.I can send you the code.(ntbutic@hotmail.com)
 
I need to learn the same process, using Excel as an interface for a program written in C++(for speed). It seems that COM is the way to go. Where is the best place to teach oneself about this. Please advise.


kgarrett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top