Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Zeilenumbruch in MS Word (Formularfeld) (https://www.delphipraxis.net/115698-zeilenumbruch-ms-word-formularfeld.html)

Harry M. 16. Jun 2008 14:55


Zeilenumbruch in MS Word (Formularfeld)
 
Hallo,
möchte gerne in MS word in ein Formularfeld einen Text hineinbringen. Soweit kein Problem. Text kommt auch an. Nur leider werden in dem Formularfeld keine Zeilenumbrüche dargestellt sondern der Text fortlaufend dargestellt, also hintereinander.

Delphi-Quellcode:
var
  Filename, vOle, Field: OleVariant;
  S: String;
  I: Integer;
begin
  FileName := ExtractFilePath(ParamStr(0)) + 'Dokument.doc';

  Self.WordApplication1.Connect;
  Self.WordApplication1.Visible := True;
  Self.WordApplication1.Documents.Open(FileName,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam,
                                       EmptyParam);

  vOle := 1;
  Field := 'input';

  for I := 1 to 10 do
    S := S + IntToStr(I) + #13#10;

  // Self.WordApplication1.Documents.Item(vOle).FormFields.Item(Field).Result := WideString(S);
  Self.WordApplication1.Documents.Item(vOle).FormFields.Item(Field). := S;

  Self.WordDocument1.Close;
  Self.WordApplication1.Disconnect;
end;
Jemand eine Idee wie ich dem Formularfeld den Zeilenumbruch erzwingen kann?
Ersatzweise würde ich auch dynamisch ein neues Feld einfügen. Es muss sich dann aber in der Folgezeile positionieren. Hab aber keine Idee.

Bernhard Geyer 16. Jun 2008 15:02

Re: Zeilenumbruch in MS Word (Formularfeld)
 
Probier mal statt #13#10 entweder mal nur #13 oder nur #10

Harry M. 16. Jun 2008 15:04

Re: Zeilenumbruch in MS Word (Formularfeld)
 
Hab ich schon.

Mein Verdacht geht dahin, das Word mit Unicode arbeitet ich aber Asci.

Bernhard Geyer 16. Jun 2008 15:09

Re: Zeilenumbruch in MS Word (Formularfeld)
 
Zitat:

Zitat von Harry M.
Hab ich schon.

Mein Verdacht geht dahin, das Word mit Unicode arbeitet ich aber Asci.

Ist (eigentlich) egal da durch die COM-Zwischenschicht eh alles nach Widestrings gewandelt wird.

mkinzler 16. Jun 2008 15:12

Re: Zeilenumbruch in MS Word (Formularfeld)
 
Dann ersetzte doch deinen Typ (z.B. mit OleVariant oder WideString)

Harry M. 16. Jun 2008 15:13

Re: Zeilenumbruch in MS Word (Formularfeld)
 
Da könntest Du recht haben.
Delphi-Quellcode:
S := S + IntToStr(I) + Chr($0000D); // #13#10;
Bringt nämlich auch nicht den gewünschten Erfolg.
Word erzeugt jetzte eine 13.

@mkinzler:
Delphi-Quellcode:
  S: oleVariant;
  S: WideString;
Bringt auch nicht den gewünschten Erfolg :(

Harry M. 16. Jun 2008 18:29

Re: Zeilenumbruch in MS Word (Formularfeld) [gelöst]
 
Hab das Problem an der Tablle ausgemacht in der das Feld lag. In einem leeren Dokument mit nur einem Formularfeld kommt der Umbruch.

Da es nicht ohne Tabelle geht nehm ich jetzt die ekRTF-Komponente.


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:25 Uhr.

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