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 Tabelle neue Zeile (https://www.delphipraxis.net/88079-tabelle-neue-zeile.html)

roth 9. Mär 2007 20:41


Tabelle neue Zeile
 
Abend!
Habe folgendes Problem ich schreibe in ein Wordfile in eine Tabelle:
Delphi-Quellcode:
      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;
nun macht es mir leider keine neue Zeile, sondern schreibt einfach weiter unter die Tabelle!
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

Remko 9. Mär 2007 21:23

Re: Tabelle neue Zeile
 
Easiest way to find out is to record a macro in Word then look at the VBS code.

roth 9. Mär 2007 21:31

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"

Remko 10. Mär 2007 13:45

Re: Tabelle neue Zeile
 
Try this:

Delphi-Quellcode:
var wdString: WideString;

  wdString := 'blabla';
  WordApplication1.Selection.Text := wdString;
  WordApplication1.Selection.MoveRight(wdCell);
or

Delphi-Quellcode:
WordApplication1.Selection.TypeText(wdString);
or just

Delphi-Quellcode:
WordApplication1.Selection.TypeText('Text');
but remember, Word expects Unicode strings (WideString)

roth 10. Mär 2007 18:38

Re: Tabelle neue Zeile
 
i try this
Delphi-Quellcode:
wordApp.Selection.typetext(text := '-');
          wordApp.Selection.moveRight(1);
and it write into the Table, but my Problem is that if the table ends it doesn't make a new colum.
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!

Remko 10. Mär 2007 19:10

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

roth 10. Mär 2007 19:20

Re: Tabelle neue Zeile
 
Okey but then it gives this Error:

[Fehler] main.pas(1050): Undefinierter Bezeichner: 'wdCell'

???

Remko 10. Mär 2007 19:27

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.

Remko 14. Mär 2007 09:17

Re: Tabelle neue Zeile
 
So is it working for you know?


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:14 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