以下是我在我的例子上加的,你看看,也许会有帮助
就是这句了:
worddoc.tables.item(1).cell(1,2).range.InlineShapes.AddPicture('E:/heartsong/0003.gif',False,True);//这就是加放入图片的语句
cell(1,2)表示第一行第2列的地方,根据你的就是cell(1,4)了,呵呵
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure InsertLines(LineNum:Integer);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
wordApp,wordDoc:Variant;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses ComObj;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
StrAdd:String;
i:Integer;
wrdSelection:Variant;
begin
//创建一个word对象
wordApp:=CreateOleObject('Word.Application');
wordApp.Visible:=true;
//创建一个word文档
wordDoc:=wordApp.Documents.Add();
wordDoc.Select;
wrdSelection:=wordApp.selection;
//在文档中插入内容
StrAdd:='插入一张图片';
wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;
wrdSelection.font.bold:=true;
wrdSelection.font.size:=15;
wrdSelection.font.Underline:=1;
wrdSelection.TypeText(StrAdd);
wrdSelection.font.Underline:=0;
wrdSelection.font.bold:=false;
wrdSelection.font.size:=11;
InsertLines(1);
//在文档中插入一个4行4列的表格,并格式化
wordDoc.Tables.Add(wrdSelection.Range,4,4,2,0);
wordDoc.Tables.Item(1).Borders.Item(1).LineStyle:=7;
wordDoc.Tables.Item(1).Borders.Item(2).LineStyle:=7;
wordDoc.Tables.Item(1).Borders.Item(3).LineStyle:=7;
wordDoc.Tables.Item(1).Borders.Item(4).LineStyle:=7;
for i:=1 to 4 do
begin
wordDoc.Tables.Item(1).Cell(i,1).Range.Bold:=true;
wordDoc.Tables.Item(1).Cell(i,3).Range.Bold:=true;
wordDoc.Tables.Item(1).Rows.Item(i).Range.Paragraphs.Alignment:=wdAlignParagraphCenter;
end;
//在第一个表格中插入内容
wordDoc.Tables.Item(1).Cell(1,1).Range.text:='岗位名称';
worddoc.tables.item(1).cell(1,2).range.InlineShapes.AddPicture('E:/heartsong/0003.gif',False,True);//这就是加放入图片的语句
wordDoc.Tables.Item(1).Cell(2,1).Range.InsertAfter('岗位级别');
wordDoc.Tables.Item(1).Cell(3,1).Range.InsertAfter('隶属部门');
wordDoc.Tables.Item(1).Cell(4,1).Range.InsertAfter('直接上级');
wordDoc.Tables.Item(1).Cell(1,3).Range.InsertAfter('岗位编号');
wordDoc.Tables.Item(1).Cell(2,3).Range.InsertAfter('现任职者');
wordDoc.Tables.Item(1).Cell(3,3).Range.InsertAfter('分支机构');
wordDoc.Tables.Item(1).Cell(4,3).Range.InsertAfter('直接下级');
//保存文档
......
end;
end.