Your question, your audience. Choose who sees your identity—and your question—with question security.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
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(Se
var
WorkBook,Sheet1,Sheet2,Cha
Sheet,SeriesCollection:Var
vrange:variant;
WD,WordDocument,wRange,Sha
i,j:integer;
begin
Excel.SheetsInNewWorkbook := 2;
WorkBook:=Excel.Workbooks.
Sheet1:=WorkBook.WorkSheet
Sheet2:=WorkBook.WorkSheet
Chart:=WorkBook.Charts.Add
Sheet1.Name:='Table 1';
Sheet2.Name:='Table 2';
for j:=1 to 2 do begin
Sheet:=WorkBook.WorkSheets
for i:=1 to 11 do begin
Sheet.Cells.Item[i,1].Valu
Sheet.Cells.Item[i,2].Valu
end;
end;
vrange:=Sheet1.range['A1:A
SeriesCollection:=Chart.Se
SeriesCollection.Add(vrang
vrange:=Sheet2.Range['B1:B
SeriesCollection.Add(vrang
Chart.Select;
Excel.Selection.Copy;
WD:=CreateOleObject('Word.
WordDocument:=WD.Documents
if Chart.PageSetup.Orientatio
then WordDocument.PageSetup.Ori
else WordDocument.PageSetup.Ori
for i:=1 to 5 do begin
WordDocument.Paragraphs.Ad
end;
wRange:=WordDocument.Range
wRange.Paste;
showmessage(inttostr(WordD
// Shape:=WordDocument.Shapes
// Shape.Height:=round(0.75*S
wRange:=WordDocument.Range
wRange.Text:='Chart From Excel ';
WD.visible:=true;
WD:=unassigned;
end;
---
to connect to excell :
procedure TfmMain.btExcelConnectClic
var
Excel1:variant;
begin
try
Excel1:=GetActiveOleObject
Excel:=Unassigned;
Excel1:=Unassigned;
Excel:=GetActiveOleObject(
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.