kherbst
asked on
Excel Ole Automation - early binding
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?
Have you already looked at the TExcel component for your purposes?
ASKER
Yes, but it uses DDE and I don't want that.
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('Exc el.Sheet', False);
oleExcel.DoVerb(ovShow);
WS := IWorkSheets(oleExcel.OleOb jectInterf ace);
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
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
var
WS: IWorkSheets;
begin
oleExcel.AutoActivate := aaManual;
oleExcel.CreateObject('Exc
oleExcel.DoVerb(ovShow);
WS := IWorkSheets(oleExcel.OleOb
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
ASKER
Do I have to use a Ole container in the process or can I use CreateOleObject?
You can use create ole object or CoCreateInstance, whichever suits your purpose.
ASKER
Thank you, I accept your answer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.