Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Problem beim Formatieren einer Word-Tabelle (https://www.delphipraxis.net/131253-problem-beim-formatieren-einer-word-tabelle.html)

Trille 21. Mär 2009 10:02


Problem beim Formatieren einer Word-Tabelle
 
Hallo allerseits, ich experimentiere momentan etwas mit Delphi und Word herum. Nun habe ich folgendes Problem:

Ich füge einem worddokument eine Tabelle hinzu, das funktioniert super. Nun möchte ich diese Tabelle folgendermaßen formatieren:


// Tabelle hinzufügen
Delphi-Quellcode:
curTable := WordDocument.Tables.Add(WordApplication.Selection.Range,100,3,_DefaultTableBehavior,_AutoFitBehavior);
       
        curTable.Cell(1, 1).Range.Font.Name := 'Arial';
        curTable.Cell(1, 1).Range.Font.Size := 8;
        curTable.Cell(1, 1).Range.Font.Color := clRed;
        curTable.Cell(1, 1).Range.Text := 'Test';
Das funktioniert auch bestens.

Jetzt probiere ich folgendes:
Delphi-Quellcode:
curTable := WordDocument.Tables.Add(WordApplication.Selection.Range,100,3,_DefaultTableBehavior,_AutoFitBehavior);
        FormatTableHeader(curTable, 'Arial', 8, clRed);


procedure TMainForm.FormatTableHeader(var tab: Table; font: TFontName; fontSize: Integer; color: Cardinal);
var
    i: integer;
begin  
        tab.Cell(1, 1).Range.Font.Name := font;
        tab.Cell(1, 1).Range.Font.Size := fontSize;
        tab.Cell(1, 1).Range.Font.Color := color;

        // temp
        tab.Cell(1, 1).Range.Text := 'Test';
end;
Jetzt fliegt mir entweder die Anwendung um die Ohren oder es wird irgendeine Zelle formatiert.
Was mache ich falsch?

Vielen Dank!


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz