![]() |
stringgrid nach MS Word Problem
hallo Leutz,
Ich hab hier einen guten Tipp gefunden, mit welchem ich ein tStringGrid nach MS Word bringe.
Delphi-Quellcode:
Nun, eigentlich funktioniert alles soweit gut. Nur schreibt der mit immer doppelt soviele cols, statt 5 macht er 10 usw. :shock: var WordApp,WordTable: OLEvariant; iRows, iCols, iGridRows, jGridCols: Integer; begin if form5.Active = true then begin Screen.Cursor := crHourglass; try // Create Word Instance WordApp := CreateOleObject('Word.Application'); except ShowMessage('Cannot start MS Word.'); Screen.Cursor := crDefault; Exit; end; try // Open a Word Document WordApp.Documents.Add(Template := ExtractFilePath(ParamStr(0))+'\doks\auftrag.dot'); // Show Word WordApp.Visible := True; // Artikel grid einfügen \\ iCols := form5.grid.ColCount; iRows := form5.grid.RowCount; // Tabelle einfügen WordTable := WordApp.ActiveDocument.Tables.Add(WordApp.ActiveDocument.FormFields.Item('artikel').Range, iCols, iRows); // Tabelle ausfüllen mit Stringgrid Daten for iGridRows := 1 to iRows do for jGridCols := 1 to iCols do WordTable.Cell(iGridRows, jGridCols).Range.Text := form5.grid.Cells[jGridCols-1, iGridRows-1]; wordapp.PrintOutOld; wordapp.Documents.Close(SaveChanges := 0); wordapp.quit; finally WordApp := Unassigned; Screen.Cursor := crDefault; end; end; end; Könnte mir vielleicht jemand einen Tipp geben, warum er das tut? :oops: Besten Dank für eure Hilfe greetz nico44 [edit] Habe gerade gemerkt, dass das Problem nur auftritt wenn ich mehr Zeilen als Spalten habe, d.h. wenn ich gleich viele Zeilen wie Spalten habe stimmt. Ich erhalte somit auch eine Fehlermeldung "das angeforderte Element ist nicht in der Sammlung vorhanden", wenn ich weniger Zeilen wie Spalten habe. greetz nico44 [edit=sakura] M$ -> MS - Du nutzt es, also kein Grund andern die Suche zu erschweren... Mfg, sakura[/edit] |
Re: stringgrid nach M$ Word Problem
hallihallo :oops:
hab's gerade selber rausgefunden: WordTable := WordApp.ActiveDocument.Tables.Add(WordApp.ActiveDo cument.FormFields.Item('artikel').Range,iRows, iCols); dieser Teil war falsch. Ich habe zuerst icols und dann irows angegeben. :stupid: tja, besten Dank gleichfalls :bouncing4: :bounce1: greetz nico44 |
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:54 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