Solved

OLE between D2 and Excel97

Posted on 1997-06-26
2
244 Views
Last Modified: 2010-04-04
What is the general syntax required to extract information from OLE with Excel97 and Delphi 2?
0
Comment
Question by:bopper
2 Comments
 
LVL 1

Accepted Solution

by:
CFantin earned 100 total points
ID: 1337829
Assuming you have a bit of knowlegde about OLE,

To extract data from cells you need to connect to excel, get the active book or any open book, get the current sheet and then you can access the individual cell data.

//Open Excel Application
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.Visible := True;

//Open a workbook
XLNewBook := ExcelApp.WorkBooks.Open('C:\My Documents\WlsTemplate.xls');
//Get Active Workbook
XLNewBook := ExcelApp.ActiveWorkbook;

//Selecting a specific worksheet in the current workbook
XLActiveSheet := XLNewBook.WorkSheets[1];
//Selecting the active workbook
XLActiveSheet := XLNewBook.ActiveWorkSheet;

//Set the cell value in the current cell
XLActiveSheet.Cells[CurrentRow, CurrentColumn].Value := 'Hello workld';
//Get current cell value
MyString := XLActiveSheet.Cells[CurrentRow, CurrentColumn].Value

You can access any object in excel using this type of method.
eg Toolbars, Menus etc.

If you have the excel help installed you can get help on the objects avalible to you.
0
 

Author Comment

by:bopper
ID: 1337830
I was so close but ever so far away from the answer, thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now