I am pasting a couple of routines from my first try with Tword.
It is word2000, so there may be some changes.
In my experience the number of parameters may vary from version to version

The actual code shown will not work, but may give some inspiration.

/Kaj


procedure TFMakeWord.FormCreate(Sender: TObject);
begin
  WordDocument1:= TWordDocument.Create(FMakeWord);
  WordApplication1:= TWordApplication.Create(FMakeWord);
  RestoreForm(Tform(Sender));
end;

procedure TFMakeWord.MakeDocument;
var
  TmpVariant9, TmpVariant8,TmpVariant, TmpVariant1,TmpVariant2, TmpVariant3,
  TmpVariant4, TmpVariant5,TmpVariant6, TmpVariant7,bt,prop: OleVariant;
  DefaultTableBehaviour, AutoFitBehaviour: OleVariant;
  NewDoc: _Document;
  i: Integer;
  Left,top,height,width: SIngle;
begin
  NewDoc := WordApplication1.Documents.Add(EmptyParam, EmptyParam, EmptyParam, 
EmptyParam);
  WordDocument1.ConnectTo(NewDoc);
  Prop := 'Heading 1';
  WordApplication1.Selection.Set_Style(prop);
  WordApplication1.Selection.TypeText('Indledning');
  WordApplication1.Selection.TypeParagraph;
  For i := 0 To EIndledning.Lines.Count -1 Do
  Begin
    WordApplication1.Selection.TypeText(EIndledning.Lines[i]);
    WordApplication1.Selection.TypeParagraph;
  End;
  bt := wdPageBreak;
  WordApplication1.Selection.InsertBreak(bt);

  With DM.ArkSQL Do
  Begin
    First;
    While Not EoF Do
    Begin
      Edit1.Text := FieldByName('BilledTitel').AsString;
      Application.ProcessMessages;
      Prop := 'Heading 1';
      WordApplication1.Selection.Set_Style(prop);
      WordApplication1.Selection.TypeText(FieldByName('BilledTitel').AsString);
      WordApplication1.Selection.TypeParagraph;

      MakeTmpImage(FieldByName('Filnavn').AsString);
      WordApplication1.Selection.InlineShapes.AddPicture(Homedir+'\tmp.bmp',
        EmptyParam,EmptyParam,EmptyParam);
      WordApplication1.Selection.TypeParagraph;
      WordApplication1.Selection.Font.Size := 8;
      WordApplication1.Selection.TypeText(FieldByName('FilNavn').AsString);
      WordApplication1.Selection.Font.Size := 12;
      WordApplication1.Selection.TypeParagraph;
      If FieldByName('IndexBillede').AsString <> '' Then
      Begin
{        DefaultTableBehaviour:= wdWord9TableBehavior;
        AutoFitBehaviour:= wdAutoFitWindow;
        
NewDoc.Tables.Add(WordApplication1.Selection.Range,1,2,DefaultTableBehaviour, 
AutoFitBehaviour);
        
WordApplication1.Selection.TypeText(FieldByName('BilledTekst').AsString);
        TmpVariant1 := wdCell;
        TmpVariant2 := 1;
        TmpVariant3 := 0;
        
WordApplication1.Selection.MoveRight(TmpVariant1,TmpVariant2,TmpVariant3);}
        MakeTmpResizedImage(FieldByName('IndexBillede').AsString);
        WordApplication1.Selection.InlineShapes.AddPicture(Homedir+'\tmp.bmp',
          EmptyParam,EmptyParam,EmptyParam);
        WordApplication1.Selection.TypeParagraph;
        
WordApplication1.Selection.TypeText(FieldByName('BilledTekst').AsString);
{        TmpVariant1 := wdLine;
        TmpVariant2 := 1;
        TmpVariant3 := 0;
        
WordApplication1.Selection.MoveDown(TmpVariant1,TmpVariant2,TmpVariant3);}
        WordApplication1.Selection.TypeParagraph;
      End
      Else
      Begin
        
WordApplication1.Selection.TypeText(FieldByName('BilledTekst').AsString);
        WordApplication1.Selection.TypeParagraph;
      End;
      bt := wdPageBreak;
      WordApplication1.Selection.InsertBreak(bt);

      Next;
    End;
  End;

  TmpVariant1 := wdGoToPage;
  TmpVariant2 := wdGoToNext;
  TmpVariant3 := unAssigned;
  TmpVariant4 := '1';
  
WordApplication1.Selection.GoTo_(tmpVariant1,TmpVariant2,TmpVariant3,TmpVariant4);
  {
  TmpVariant := 'UseHeadingStyles:=True';
  TmpVariant1 := 'UpperHeadingLevel:=1';
  TmpVariant2 := 'LowerHeadingLevel:=3';
  TmpVariant3 := 'UseFields:=false';
  TmpVariant4 := '';
  TmpVariant5 := 'RightAlignPageNumbers:=True';
  TmpVariant6 := 'IncludePageNumbers:=True';
  TmpVariant7 := 'AddedStyles:=""';
  TmpVariant8 := 'UseHyperlinks:=True';
  TmpVariant9 := 'HidePageNumbersInWeb:=True';}
  TmpVariant := true;
  TmpVariant1 := '1';
  TmpVariant2 := '3';
  TmpVariant3 := false;
  TmpVariant4 := unassigned;
  TmpVariant5 := True;
  TmpVariant6 := True;
  TmpVariant7 := unAssigned;
  TmpVariant8 := True;
  TmpVariant9 := True;
  
WordApplication1.ActiveDOcument.TablesOfContents.Add(WordApplication1.Selection.Range,
  
TmpVariant,TmpVariant1,TmpVariant2,TmpVariant3,TmpVariant4,TmpVariant5,TmpVariant6,
  TmpVariant7,TmpVariant8,TmpVariant9);
  bt := wdPageBreak;
  WordApplication1.Selection.InsertBreak(bt);

  TmpVariant := Spd1.FileName;
  TmpVariant2 := False;
  WordDocument1.SaveAs(TmpVariant, EmptyParam,
    EmptyParam, EmptyParam, TmpVariant2);
  WordApplication1.Quit(TmpVariant2);
  MessageDlg('Word dokument er dannet',mtInformation,[mbOK],0);
  Close;
end;

  -----Original Message-----
  From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of Rob 
Kennedy
  Sent: 21. juli 2005 18:26
  To: [email protected]
  Subject: Re: [delphi-en] Re: Working with TWordDocument


  ytskeynan wrote:
  > --- In [email protected], Rob Kennedy <[EMAIL PROTECTED]> wrote:
  >> So? Neither Delphi nor Office has changed very much over the years.
  > 
  > Sure, but Delphi has changed its unit Word_TLB

  You can name the file anything you want when you import the type library.

  > and made WordXP with different functions, properties & methods.

  All the old properties and methods are still there. The Word XP
  automation object supports the interfaces of previous versions.

  >> Word is a Microsoft product. Have you looked in MSDN yet?
  > 
  > I didn't mean to ask how to learn about Microsoft Word, but how to
  > use DELPHI's WordXP unit.

  That unit is nothing more than a list of declarations of objects
  implemented by Microsoft. Borland hasn't added anything significant to
  that unit.

  -- 
  Rob


  -----------------------------------------------------
  Home page: http://groups.yahoo.com/group/delphi-en/
  To unsubscribe: [EMAIL PROTECTED] 



------------------------------------------------------------------------------
  YAHOO! GROUPS LINKS 

    a..  Visit your group "delphi-en" on the web.
      
    b..  To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]
      
    c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


------------------------------------------------------------------------------



[Non-text portions of this message have been removed]



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to