?
Solved

insert an Excel chart into a word Document ??

Posted on 2000-04-26
7
Medium Priority
?
453 Views
Last Modified: 2010-04-04
if you have a chart which is  contained in a specific sheet in the spreadsheet, How do you place the CHART AREA in the word doc ?  What am I trying to accomplish ?  I have stored with in spread sheet sheets chart objects and would like to insert these charts in to a mail merge doc., that is to say chart 1 from sheet1 is placed om page1 of the doc chart2 from sheet will be placed on page 2 of the doc...and so on


Using D 5.01 Pro and Late binding.
None of the server components have been used.
 Paul sutton
0
Comment
Question by:psutton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2753373
Just a thought, maybe you could build a macro that does the main part of the job. Then this macro can be called from Delphi...

Look here for info on Excel and Word automation:

http://www.djpate.freeserve.co.uk/Automation.htm


Regards,

Epsylon.
0
 

Author Comment

by:psutton
ID: 2753446
Macros are out at least at this time.
0
 

Author Comment

by:psutton
ID: 2753865
Adjusted points from 400 to 600
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:robert_marquardt
ID: 2754237
Do it in Word and record it as macro. Then have a look at the macro source. Reimplementing this in Delphi should be easier then.
0
 
LVL 4

Accepted Solution

by:
jeurk earned 2400 total points
ID: 2754463
Hello,
You should do a cut and paste,
here is a sample that shows how to create a chart with excell and we copy paste it to a word doc.
we are assuming that we are already connected to excell.
the word connxion is done here.
here we goes :

procedure TfmMain.btExample5Click(Sender: TObject);
var
 WorkBook,Sheet1,Sheet2,Chart:variant;
 Sheet,SeriesCollection:Variant;
 vrange:variant;
 WD,WordDocument,wRange,Shape:variant;
 i,j:integer;
begin
 Excel.SheetsInNewWorkbook := 2;
 WorkBook:=Excel.Workbooks.Add;
 Sheet1:=WorkBook.WorkSheets[1];
 Sheet2:=WorkBook.WorkSheets[2];
 Chart:=WorkBook.Charts.Add;
 Sheet1.Name:='Table 1';
 Sheet2.Name:='Table 2';
 for j:=1 to 2 do begin
  Sheet:=WorkBook.WorkSheets[j];
  for i:=1 to 11 do begin
   Sheet.Cells.Item[i,1].Value:=i;
   Sheet.Cells.Item[i,2].Value:=i*2;
  end;
 end;
 vrange:=Sheet1.range['A1:A10'];
 SeriesCollection:=Chart.SeriesCollection;
 SeriesCollection.Add(vrange);
 vrange:=Sheet2.Range['B1:B10'];
 SeriesCollection.Add(vrange);
 Chart.Select;
 Excel.Selection.Copy;
 WD:=CreateOleObject('Word.Application');
 WordDocument:=WD.Documents.Add;
 if Chart.PageSetup.Orientation=xlLandscape
 then WordDocument.PageSetup.Orientation:=wdOrientLandscape
 else WordDocument.PageSetup.Orientation:=wdOrientPortrait;
 for i:=1 to 5 do begin
  WordDocument.Paragraphs.Add;
 end;
 wRange:=WordDocument.Range(0,1);
 wRange.Paste;
 showmessage(inttostr(WordDocument.Shapes.Count));
// Shape:=WordDocument.Shapes.Item(WordDocument.Shapes.Count);
// Shape.Height:=round(0.75*Shape.Height);
 wRange:=WordDocument.Range(2,2);
 wRange.Text:='Chart From Excel ';
 WD.visible:=true;
 WD:=unassigned;
end;

---

to connect to excell :
procedure TfmMain.btExcelConnectClick(Sender: TObject);
var
 Excel1:variant;
begin
 try
  Excel1:=GetActiveOleObject('Excel.Application');
  Excel:=Unassigned;
  Excel1:=Unassigned;
  Excel:=GetActiveOleObject('Excel.Application');
  isConnected:=true;
 except
  Excel:=Unassigned;
  showmessage('Active Excel not found');
 end;
 RefreshInfo;
 SetForegroundWindow(Handle);
end;

if you give me an email, i'll send you the whole project doing excell automation stuff.
I can't remember where I found so I'm unable to give you the link...
Regards.
0
 

Author Comment

by:psutton
ID: 2755308
Thanks. Your answer was prety much what I had in mind, I just didn't know how to get the different charts in to word.
email addr is psutton0623@yahoo.com
0
 
LVL 4

Expert Comment

by:jeurk
ID: 2755330
You're welcome. I sent it.
-Jeurk.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

765 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