1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | procedure EncrustImage(); var WordApplication, WordDocument, CurrentPic: Variant; cnt, rgn: variant; begin try WordApplication := CreateOleObject( 'Word.Application' ); WordDocument := WordApplication . Documents . Open(Edit1 . Text); //get to the last position of the caret cnt := WordDocument . Characters . Count; cnt := cnt - 1 ; rgn := WordDocument . Range(Start := cnt, end := cnt); if path1 . text <> '' then begin rgn . InlineShapes . AddPicture(path1 . text); CurrentPic := WordApplication . ActiveDocument . InlineShapes . Item( 1 ); Currentpic . Height := 170.0 ; // points Currentpic . Width := 225.0 ; end ; cnt := WordDocument . Characters . Count; cnt := cnt - 1 ; rgn := WordDocument . Range(Start := cnt, end := cnt); if path2 . text <> '' then begin rgn . InlineShapes . AddPicture(path2 . text); CurrentPic := WordApplication . ActiveDocument . InlineShapes . Item( 2 ); Currentpic . Height := 170.0 ; // points Currentpic . Width := 225.0 ; end ; cnt := WordDocument . Characters . Count; cnt := cnt - 1 ; rgn := WordDocument . Range(Start := cnt, end := cnt); rgn . Text := chr( 13 ) + chr( 10 ); WordDocument . SaveAs(FileName := Edit2 . text + '\out' + ExtractFileName(Edit1 . text), AddToRecentFiles := False ); WordApplication . Quit( False ); except WordApplication . Quit( False ); end ; end ; |