Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to read the content of an Excel object embedded in a Word document Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
19-Dec-02
Category
OLE
Language
Delphi 4.x
Views
190
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I have an Excel object in a Word document. I want to read the content of the Excel 
object from my Delphi program. How can I do that?

Answer:

1   { ... }
2   var
3     AWordApplication: WordApplication;
4     AWordDocument: WordDocument;
5     AWorkBook: ExcelWorkBook;
6     AWorkSheet: ExcelWorkSheet;
7     AInlineShape: InlineShape;
8     AFileName: OleVariant;
9     TrueParam: OleVariant;
10  begin
11    AWordApplication := CoWordApplication.Create;
12    try
13      FalseParam := False;
14      AFileName := 'c:\wordexcel.doc';
15      AWordDocument := AWordApplication.Documents.Open(AFileName, EmptyParam,
16        EmptyParam,
17        EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
18        EmptyParam, EmptyParam, EmptyParam, EmptyParam);
19      AInlineShape := AWordDocument.InlineShapes.Item(1);
20      AInlineShape.Activate;
21      AWorkBook := AWordDocument.InlineShapes.Item(1).OLEFormat.Object_ as
22        ExcelWorkBook;
23      AWorkSheet := AWorkBook.ActiveSheet as ExcelWorkSheet;
24      ShowMessage(AWorkSheet.Cells.Item[2, 1].Text);
25    finally
26      AWordApplication.Quit(FalseParam, EmptyParam, EmptyParam);
27      AWordApplication := nil;
28      AWordDocument := nil;
29    end;
30  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC