Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Problem mit S: Selection (https://www.delphipraxis.net/38421-problem-mit-s-selection.html)

freak4fun 19. Jan 2005 10:04


Problem mit S: Selection
 
Hallo kann mir einer sagen was das ist?

Delphi-Quellcode:
var  
S: Selection; // <-- Kennt mein Delphi net
 
...  
S :=Word.Selection;  
S.TypeText('Here is some text');  
S.TypeParagraph;  
S.TypeParagraph;  
S.TypeText('And there was a blank line.');
Ich habs von hier.

Marcel Gascoyne 19. Jan 2005 10:16

Re: Problem mit S: Selection
 
Ich nehme an das dies ein Objekt aus Winword ist. Du hast wahrscheinlich die entsprechende Unit für Dein Office nicht eingebunden, daher kennt Delphi das nicht.

Gruß,
Marcel

freak4fun 19. Jan 2005 10:25

Re: Problem mit S: Selection
 
So weit ich das verstehe hast du recht. :gruebel:

Ich hab es jetzt so gemacht:

Weil S: Selection nicht geht und S dann einfach nur Word.Selction zugewiesen wird hab ich das S halt direct durch Word.Selection ersetzt. Ist ja auch logisch. :mrgreen:
Aber ich kann das Word.Selection nicht mit "with" aufrufen. :cry:

Delphi-Quellcode:
with Word.Selection do begin // <-- Fehler: Record, object or class type required
  TypeText('Hallo!');
end;
mfg
freak

shmia 19. Jan 2005 11:10

Re: Problem mit S: Selection
 
Du kannst späte Bindung über die IDispatch Schnittstelle benützen:
Delphi-Quellcode:
var  
S: OleVariant; // <=====
...  
S :=Word.Selection;  
S.TypeText('Here is some text');  
S.TypeParagraph;  
S.TypeParagraph;  
S.TypeText('And there was a blank line.');
Die With-Anweisung kann natürlich nicht funktionieren, da bei später Bindung der Delphi
Kompiler keine Ahnung hat, was sich hinter OleVariant versteckt.
Die Zeile
Code:
S.TypeText('Here is some text');
verursacht im Hintergrund folgendes:
* dein Programm fragt WinWord, nach der Nummer der Funktion TypeText
* Word antwortet mit der Nummer der Funktion und den möglichen Parametern
* dein Programm sendet die Nummer der Funktion + Parameter an Word
* Word führt die Funktion aus und gibt evtl. einen Rückgabewert zurück


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