Solved

insert an Excel chart into a word Document ??

Posted on 2000-04-26
7
430 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
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
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.

 
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 600 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

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

912 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

20 Experts available now in Live!

Get 1:1 Help Now