Board index » delphi » D5, Word97 import Jpg's

D5, Word97 import Jpg's

I would like to import jpg's into a word 97 document under program control.
Any thoughts on how this is done?

TIA
David__Star(at)e{*word*277}.com

 

Re:D5, Word97 import Jpg's


To anyone that wants to insert a jpg into a word document please see the code below. I added it to the Word8Auto project in the demos directory.

All the best
David__S...@e{*word*277}.com

procedure TForm1.Button3Click(Sender: TObject);
var
  CurDir   : string ;
  FileName : string ;
  OleF, OleT : OleVariant ;
  Left, Top, Width, Height, Anchor : OleVariant ; //
  RangeIndex : OleVariant ;

begin
  CurDir := GetCurrentDir ;
  filename := CurDir+'\Calvin.jpg' ;
  OleF := false ;
  OleT := true ;
  If WordDoc = nil then
    WordDoc := TWordDocument.Create( Form1.owner ) ; ;

  WordDoc.Connectto( Wordobject.Application.ActiveDocument ) ;
  worddoc.range.find.ClearFormatting ;

  Top    :=  40 ;
  Left   := 370 ;
  Width  := 320 ;
  Height := 320 ;
  Anchor := worddoc.Content ;
  memo1.lines.add( 'worddoc.Content.Get_Start['+ inttostr( worddoc.Content.Get_Start )+ ']' ) ;
  memo1.lines.add( 'worddoc.Content.Get_Start['+ inttostr( worddoc.Content.Get_End_  )+ ']' ) ;

  RangeIndex := 0 ;
  RangeIndex := worddoc.Shapes.Count ;
  memo1.lines.add( 'worddoc.Shapes.Count['+ inttostr( RangeIndex  )+ ']' ) ;

  WordDoc.Shapes.AddPicture( FileName,    // const FileName: WideString;
                             OleF,        // var LinkToFile: OleVariant;
                             OleT,        // var SaveWithDocument: OleVariant;
                             Left,        // var Left: OleVariant;
                             Top,         // var Top: OleVariant;
                             Width,       // var Width: OleVariant;
                             Height,      // var Height: OleVariant;
                             Anchor       // var Anchor: OleVariant): Shape; safecall;
                            ) ;

  RangeIndex := worddoc.Shapes.Count ;
  memo1.lines.add( 'worddoc.Shapes.Count['+ inttostr( RangeIndex  )+ ']' ) ;
  worddoc.Shapes.Range( RangeIndex ).WrapFormat.Set_Type_( wdWrapNone );

  WordDoc.Disconnect ;
end;

Quote
"David Star" david__star(at)e{*word*277}.com wrote:

>I would like to import jpg's into a word 97 document under program control.
>Any thoughts on how this is done?

>TIA
>David__Star(at)e{*word*277}.com

Other Threads