Solved

OLE between D2 and Excel97

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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