Solved

OLE between D2 and Excel97

Posted on 1997-06-26
2
242 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

20 Experts available now in Live!

Get 1:1 Help Now