delphi怎样向word中指定位置插入图片?
var
LinkToFile, SaveWithDocument, Range: olevariant;begin
WordDocument1.Range.InsertAfter('我的图片'+#13);
WordDocument1.Range.InsertAfter('同学' +#13);//例如全面加了很多类似的文字,我想接着加图片 LinkToFile := False;
SaveWithDocument := True;
WordApplication1.Selection.InlineShapes.AddPicture('e:\11.jpg',LinkToFile,SaveWithDocument,EmptyParam);
end;但发现图片居然加上最上面,有没有办法接着加在鼠标当前的位置啊?具体的代码怎样
var
LinkToFile, SaveWithDocument, Range: olevariant;begin
WordDocument1.Range.InsertAfter('我的图片'+#13);
WordDocument1.Range.InsertAfter('同学' +#13);//例如全面加了很多类似的文字,我想接着加图片 LinkToFile := False;
SaveWithDocument := True;
WordApplication1.Selection.InlineShapes.AddPicture('e:\11.jpg',LinkToFile,SaveWithDocument,EmptyParam);
end;但发现图片居然加上最上面,有没有办法接着加在鼠标当前的位置啊?具体的代码怎样
解决方案 »
- 数组指针问题,看起来简单做起来复杂,大家帮忙啊!
- 如何制做能打印的统计图,有现在的控件吗?
- 用DELPHI对WORD进行编辑
- 关于SQLConnection的连接问题?
- 小弟是DELPHI的一只菜鸟,各位能帮我解决吗?
- 线程问题,很郁闷!
- 怎样生成TStringList型变量的副本
- 动态设置QRexpr的expression提示出错,错误为:Unterminated string constant,请高手帮忙看一看,急急急
- 救急!如何控制高速扫描仪批量扫描并保存为相应文件名?
- 请问怎样在Delphi中使用DirectX?怎样制作DirectX窗口?
- delphi如何从剪切板中获得被复制的文件的路径
- delphi如何实现与android平台的通讯?
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, Word97, OleServer; type
TForm1 = class(TForm)
App: TWordApplication;
Doc: TWordDocument;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
odDoc: TOpenDialog;
SpeedButton6: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.DFM} procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
APP.Connect;
app.Visible := true;
end; procedure TForm1.SpeedButton2Click(Sender: TObject);
var Index,sFile,bFlag:OleVariant;
begin
if odDoc.Execute then
begin
sFile:=odDoc.FileName;
bFlag := False;
App.Documents.Open(sFile,bFlag,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
index :=1;
Doc.ConnectTo(App.Documents.Item(index));
end
else
begin
///Documents.Add DocumentType:=wdNewBlankDocument
// ShowVisualBasicEditor = True
///
app.Documents.Add(EmptyParam,EmptyParam);
end;
end; procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
Doc.PrintPreview;
end; procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
// Selection.TypeText Text:= "uiyuiyuiyuiyuyuyui "
///这是我录的插入字符的宏
// 思想:宏转换在 vb转换要容易些
app.Selection.TypeText( 'dfjalfda;fdsajfla '); end; procedure TForm1.SpeedButton5Click(Sender: TObject);
var
LinkToFile, SaveWithDocument:OleVariant;
begin
// Selection.InlineShapes.AddPicture FileName:= "F:\新建文件夹 (2)\BLOW4.JPG ", _
// LinkToFile:=False, SaveWithDocument:=True
odDoc.FileName := 'F:\新建文件夹 (2)\BLOW4.JPG ';
if odDoc.Execute then
begin
LinkToFile:=False; SaveWithDocument:=True;
app.Selection.InlineShapes.AddPicture(odDoc.FileName,LinkToFile,SaveWithDocument,EmptyParam); end;
{插入表格也类是 用range 可以控制插入的位置}
end; procedure TForm1.SpeedButton6Click(Sender: TObject);
var
append,FileName, Range, Item, Copies, Pages, PageType , ManualDuplexPrint
, Collate, Background, PrintToFile , PrintZoomColumn, from,to_ ,
PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight:OleVariant; begin
{ '
' Macro3 Macro
' 宏在 2001-7-24 由 yj 录制
'
Application.PrintOut FileName:= " ", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:= "11 ", PageType:=wdPrintAllPages _
, ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile _
:=False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
}
FileName:= ' '; Range:= 'wdPrintRangeOfPages '; Item:= 'wdPrintDocumentContent ';
Copies:=1; Pages:=2; PageType:= 'wdPrintAllPages ';
ManualDuplexPrint:=False; Collate:=True; Background:=True; PrintToFile :=False; PrintZoomColumn:=0; PrintZoomRow:=0;
PrintZoomPaperWidth:=0;
PrintZoomPaperHeight:=0 ;
append:=false;
from:=2;
to_:=2;
app.PrintOut(Background,Append , Range, filename, from, to_, Item, Copies, Pages, PageType, PrintToFile, Collate, FileName, EmptyParam, ManualDuplexPrint)//, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight) {(Background,EmptyParam,EmptyParam,filename,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,pages,EmptyParam,EmptyParam);}
end; end.
将指针移动到位置再插入图片