Problems with Word

soxnox

New Member
I want to get the text, which is saved in a word-file. The Character-Variable is to small to get large texts.
Now I want to get the text by each line.

Who can help?

greetings Oliver
 
U

Unregistered

Guest
The following code will go through each line of the document and display the text.


DEFINE VARIABLE hWord AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hDocument AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE intLine AS INTEGER NO-UNDO.
DEFINE VARIABLE strLine AS CHARACTER NO-UNDO.

CREATE "Word.Application" hWord.

hWord:Visible = False.

hDocument = hWord:Documents:Open("c:\test.doc").

DO intLine = 1 TO hDocument:ComputeStatistics(1):
hWord:Selection:GoTo(3,1,intLine).
hWord:Selection:MoveEnd(5, 1).

ASSIGN strLine = hWord:Selection:Text.
MESSAGE strLine.
END.

hWord:QUIT.

RELEASE OBJECT hWord NO-ERROR.
RELEASE OBJECT hDocument NO-ERROR.
 
Top