![]() |
Tabelle neue Zeile
Abend!
Habe folgendes Problem ich schreibe in ein Wordfile in eine Tabelle:
Delphi-Quellcode:
nun macht es mir leider keine neue Zeile, sondern schreibt einfach weiter unter die Tabelle!
wordApp.Selection.typetext(text :='Test');
wordApp.Selection.moveRight; wordApp.Selection.typetext(text :='Test'); wordApp.Selection.moveRight; wordApp.Selection.typetext(text :='Test'); wordApp.Selection.moveRight; wordApp.Selection.typetext(text :='Test'); wordApp.Selection.moveRight; Wie kann ich diese Problem lösen, sodass es mir immer eine Zeile anhängt sobald es die letzte Zelle ist in der Tabelle!? mfg roth |
Re: Tabelle neue Zeile
Easiest way to find out is to record a macro in Word then look at the VBS code.
|
Re: Tabelle neue Zeile
yes sure! But how looks the Delphicode with this VBS Macro Code :
Delphi-Quellcode:
Selection.TypeText Text:="test"
Selection.MoveRight Unit:=wdCell Selection.TypeText Text:="test" Selection.MoveRight Unit:=wdCell Selection.TypeText Text:="test" |
Re: Tabelle neue Zeile
Try this:
Delphi-Quellcode:
or
var wdString: WideString;
wdString := 'blabla'; WordApplication1.Selection.Text := wdString; WordApplication1.Selection.MoveRight(wdCell);
Delphi-Quellcode:
or just
WordApplication1.Selection.TypeText(wdString);
Delphi-Quellcode:
but remember, Word expects Unicode strings (WideString)
WordApplication1.Selection.TypeText('Text');
|
Re: Tabelle neue Zeile
i try this
Delphi-Quellcode:
and it write into the Table, but my Problem is that if the table ends it doesn't make a new colum.
wordApp.Selection.typetext(text := '-');
wordApp.Selection.moveRight(1); How can I write into the Table and if the Table ends it should make a new colum!?!?!? So as you will klick the Tab-Key in the Word! |
Re: Tabelle neue Zeile
Use wordApp.Selection.moveRight(wdCell) instead of wordApp.Selection.moveRight(1);
wdCell is a constant which is declared in the Word type library, this moves right one cell instead of one character |
Re: Tabelle neue Zeile
Okey but then it gives this Error:
[Fehler] main.pas(1050): Undefinierter Bezeichner: 'wdCell' ??? |
Re: Tabelle neue Zeile
It's a constant declared in the Word type library, usually this in in the folder {BDS}\Imports folder, depending on the Word version it's probably Word2000 or WordXP. If you don't have that, import the type library yourself (replace Office 8.0 with your office version).
To import the Word type library, Choose Project|Import Type Library. In the Import Type Library dialog, Select Microsoft Office 8.0 Object Library. If Word ( Version 8 ) is not in the list, choose the Add button, go to Program Files\Microsoft Office\Office, select the Word type library file, MSWord8.olb choose Add, and then select Word ( Version 8 ) from the list. In Palette Page, choose Servers. Choose Install. The Install dialog appears. Select the Into New Packages tab and type WordExample to create a new package containing this type library. |
Re: Tabelle neue Zeile
So is it working for you know?
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:16 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