[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

insert an Excel chart into a word Document ??

Posted on 2000-04-26
7
Medium Priority
?
465 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

650 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