我是在delphi中用olecontainer操作word,要向其中插入图片,使用粘贴板。但是图片放入后位置是这一行的开始位置,如下:
{ 将一副图片粘贴到word中 }
ClipBoard.Assign(aImage.Picture);
{ 以下为vba代码--可在word中利用录制宏的功能取得--------------------bagin }
{ 使用vba之前加 x.OleObject.application 例如:excel添加工作表 }
{ oc.OleObject.application.sheets.Add; }
intInlineShapesIndex:=ocDoc.OleObject.application.ThisDocument.InlineShapes.Count+1;
intShapesIndex:=ocDoc.OleObject.application.ThisDocument.Shapes.Count+1;
//从剪贴板添加一个图片
ocDoc.OleObject.application.Selection.Paste;
//转换为图形
ocDoc.OleObject.application.ThisDocument.InlineShapes(intInlineShapesIndex).ConvertToShape;
//设置文字环绕方式
ocDoc.OleObject.application.ThisDocument.Shapes(intShapesIndex).WrapFormat.Type := 'wdWrapThrough';
//将图片中的白色设为透明色
ocDoc.OleObject.application.Selection.InlineShapes(intShapesIndex).PictureFormat.TransparentBackground := 'msoTrue';
ocDoc.OleObject.application.Selection.InlineShapes(intShapesIndex).PictureFormat.TransparencyColor:='RGB(255,255,255)';
ocDoc.OleObject.application.Selection.InlineShapes(intShapesIndex).Fill.Visible := 'msoFalse';
{ 以上为vba代码--可在word中利用录制宏的功能取得----------------------end } Top
{ 将一副图片粘贴到word中 }
ClipBoard.Assign(aImage.Picture);
{ 以下为vba代码--可在word中利用录制宏的功能取得--------------------bagin }
{ 使用vba之前加 x.OleObject.application 例如:excel添加工作表 }
{ oc.OleObject.application.sheets.Add; }
intInlineShapesIndex:=ocDoc.OleObject.application.ThisDocument.InlineShapes.Count+1;
intShapesIndex:=ocDoc.OleObject.application.ThisDocument.Shapes.Count+1;
//从剪贴板添加一个图片
ocDoc.OleObject.application.Selection.Paste;
//转换为图形
ocDoc.OleObject.application.ThisDocument.InlineShapes(intInlineShapesIndex).ConvertToShape;
//设置文字环绕方式
ocDoc.OleObject.application.ThisDocument.Shapes(intShapesIndex).WrapFormat.Type := 'wdWrapThrough';
//将图片中的白色设为透明色
ocDoc.OleObject.application.Selection.InlineShapes(intShapesIndex).PictureFormat.TransparentBackground := 'msoTrue';
ocDoc.OleObject.application.Selection.InlineShapes(intShapesIndex).PictureFormat.TransparencyColor:='RGB(255,255,255)';
ocDoc.OleObject.application.Selection.InlineShapes(intShapesIndex).Fill.Visible := 'msoFalse';
{ 以上为vba代码--可在word中利用录制宏的功能取得----------------------end } Top