要用程序在word中中插入一张图片,要把图片的版式设置成“衬于文字下方”“右对齐”,
我已经实现了插入图片,但不知道怎么设置版式,我录制了宏也没有从代码中看出怎么做,
请各位大侠帮忙[:)]
TypeParagraph;
oLinkToFile := False;
oSaveWithDocument := True;
sFileName := 'a.jpg';
Selection.InlineShapes.AddPicture(sFileName, oLinkToFile, oSaveWithDocument, EmptyParam);
我已经实现了插入图片,但不知道怎么设置版式,我录制了宏也没有从代码中看出怎么做,
请各位大侠帮忙[:)]
TypeParagraph;
oLinkToFile := False;
oSaveWithDocument := True;
sFileName := 'a.jpg';
Selection.InlineShapes.AddPicture(sFileName, oLinkToFile, oSaveWithDocument, EmptyParam);
W.Visible := True;
W.Documents.Add;
W.ActiveDocument.SaveAs('TestDoc.doc');
W.Selection.TypeText('Here goes my picture:');
W.Selection.TypeParagraph;
//---- insert picture: name, link to file, save with document
W.Selection.InlineShapes.AddPicture( 'C:\z\testpic.jpg', False, True );
W.Selection.TypeParagraph;
W.Quit;// see also MS Word OLE reference在 W.Selection.TypeParagraph; 設置!!!
修改图片的版式,图片的版式设置成“衬于文字下方”“右对齐”要求相当于在图片上点鼠标右键,选"设置图片格式...",选中"版式"页,
把版式设置成“衬于文字下方”“右对齐”,这些操作要用代码实现:)
var filename, Flag, PicName, PicTop, PicLeft, PicWid, PicHie, issave, PicItem, IsToSave, range, start: olevariant;
sta: integer;
begin
WordDocument1.ConnectTo(WordApplication1.ActiveDocument);
issave := true;
PicName := ExtractFilepath(application.ExeName) + 'date\dy.jpeg'; start := WordDocument1.Paragraphs.Item(WordDocument1.Paragraphs.Count).Range.End_ - 1;//这是最后一段,你想右对齐的话自已想办法定义吧
range := WordDocument1.Range(start); WordDocument1.Shapes.AddPicture(PicName, Flag, Issave, emptyparam, emptyparam, emptyparam, emptyparam, range);
PicItem := WordDocument1.Shapes.Count;
WordDocument1.Shapes.Item(PicItem).WrapFormat.Type_ := wdWrapNone;//
WordDocument1.Shapes.Item(PicItem).ZOrder(4); WordApplication1.Disconnect;end;
代码发到 把#换成@
我先送您1000分
http://expert.csdn.net/Expert/topic/2918/2918507.xml?temp=.6022455
http://expert.csdn.net/Expert/topic/2918/2918516.xml?temp=.306164
http://expert.csdn.net/Expert/topic/2918/2918523.xml?temp=.8352167
http://expert.csdn.net/Expert/topic/2918/2918545.xml?temp=.444668
http://expert.csdn.net/Expert/topic/2918/2918552.xml?temp=.8274195
http://expert.csdn.net/Expert/topic/2918/2918555.xml?temp=.0464136
http://expert.csdn.net/Expert/topic/2918/2918581.xml?temp=.1062433
http://expert.csdn.net/Expert/topic/2918/2918588.xml?temp=.4567682
http://expert.csdn.net/Expert/topic/2918/2918594.xml?temp=.1814997
http://expert.csdn.net/Expert/topic/2918/2918599.xml?temp=.1189997