Solved

Excel Ole Automation - early binding

Posted on 1997-11-28
7
490 Views
Last Modified: 2010-04-04
I am currently using late binding to automate Excel from Delphi 3. This is understandbly slow. Could anyone explain to me how to use the early binding approach and the importing of typelibs in this process?
0
Comment
Question by:kherbst
  • 3
  • 3
7 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1352337
Have you already looked at the TExcel component for your purposes?
0
 

Author Comment

by:kherbst
ID: 1352338
Yes, but it uses DDE and I don't want that.
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1352339
Hi

The following example has an OLE Container on a form (oleExcel) and I use that to get the IWorkSheet interface (which is declared in the Excel type library).

procedure TForm1.Button1Click(Sender: TObject);
var
    WS: IWorkSheets;
begin
    oleExcel.AutoActivate := aaManual;
    oleExcel.CreateObject('Excel.Sheet', False);
    oleExcel.DoVerb(ovShow);
    WS := IWorkSheets(oleExcel.OleObjectInterface);
    WS.PrintPreview(False, 0);
end;

To import the type library, choose "Import Type Library" from the Project menu and find the file called "Excel8.olb" in your MSOffice\Office path.  (I am using Delphi 3 with Office 97.)

Regards,
JB
0
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.

 

Author Comment

by:kherbst
ID: 1352340
Do I have to use a Ole container in the process or can I use CreateOleObject?
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1352341
You can use create ole object or CoCreateInstance, whichever suits your purpose.
0
 

Author Comment

by:kherbst
ID: 1352342
Thank you, I accept your answer.
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 200 total points
ID: 1352343
I guess this is the answer then...   :)

JB
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

Suggested Solutions

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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

15 Experts available now in Live!

Get 1:1 Help Now