S
skyherohuang
Unregistered / Unconfirmed
GUEST, unregistred user!
下面是我的一个代码:
var
bmp:tbitmap;
WordApp,WordDoc:OleVariant;
trow,i:integer;
afterrowlevariant;
begin
try
wordapp:=getactiveoleobject('word.application');//;这边会出错;'
except
try
WordApp:=CreateOleObject('Word.Application');//这边会出错;
except
exit;
end;
end;
WordApp.Visible:=True;
WordDoc:=WordApp.Documents.Add(template:='C:/WINDOWS/Profiles/ks/Application Data/Microsoft/Templates/quotation.dot',NewTemplate := False);
if savedialog1.execute then
wordapp.activedocument.saveas(savedialog1.filename);
i:=1;
table2.First;
while not table2.Eof do
begin
trow := worddoc.tables.item(2).Rows.Count;
afterrow := worddoc.tables.item(2).Rows.last;
worddoc.tables.item(2).Rows.Add(afterrow);
if not table2['photo']<>'' then
begin
bmp:=tbitmap.create;
bmp.Assign(image1.Picture.graphic);
ClipBoard.Assign(bmp);
worddoc.tables.item(2).cell(trow,i).range.paste;
end;
worddoc.tables.item(2).cell(trow, i+1).range.text := table2.fieldbyname('productid').asstring;
worddoc.tables.item(2).cell(trow,i+2).range.text:=table2.fieldbyname('ibox').asstring;
worddoc.tables.item(2).cell(trow,i+2).range.insertafter(#13);>
worddoc.tables.item(2).cell(trow,i+2).range.text:='acbd';
在这当中表格第二例中不能产生两行('ibox'的值与'ABCD),只有'ABCD',我发现(#13 )在cell中换不了行各位有什么看法??
table2.next;
end;
end;
原来的输出结果是
productid: ibox/abcd
ibox1
1
abcd
-------------------------
2 ibox2
abcd
现结果输出:
productid, ibox/abcd
1 abcd
-------------------------
2 abcd
var
bmp:tbitmap;
WordApp,WordDoc:OleVariant;
trow,i:integer;
afterrowlevariant;
begin
try
wordapp:=getactiveoleobject('word.application');//;这边会出错;'
except
try
WordApp:=CreateOleObject('Word.Application');//这边会出错;
except
exit;
end;
end;
WordApp.Visible:=True;
WordDoc:=WordApp.Documents.Add(template:='C:/WINDOWS/Profiles/ks/Application Data/Microsoft/Templates/quotation.dot',NewTemplate := False);
if savedialog1.execute then
wordapp.activedocument.saveas(savedialog1.filename);
i:=1;
table2.First;
while not table2.Eof do
begin
trow := worddoc.tables.item(2).Rows.Count;
afterrow := worddoc.tables.item(2).Rows.last;
worddoc.tables.item(2).Rows.Add(afterrow);
if not table2['photo']<>'' then
begin
bmp:=tbitmap.create;
bmp.Assign(image1.Picture.graphic);
ClipBoard.Assign(bmp);
worddoc.tables.item(2).cell(trow,i).range.paste;
end;
worddoc.tables.item(2).cell(trow, i+1).range.text := table2.fieldbyname('productid').asstring;
worddoc.tables.item(2).cell(trow,i+2).range.text:=table2.fieldbyname('ibox').asstring;
worddoc.tables.item(2).cell(trow,i+2).range.insertafter(#13);>
worddoc.tables.item(2).cell(trow,i+2).range.text:='acbd';
在这当中表格第二例中不能产生两行('ibox'的值与'ABCD),只有'ABCD',我发现(#13 )在cell中换不了行各位有什么看法??
table2.next;
end;
end;
原来的输出结果是
productid: ibox/abcd
ibox1
1
abcd
-------------------------
2 ibox2
abcd
现结果输出:
productid, ibox/abcd
1 abcd
-------------------------
2 abcd