ich bin gerade dabei Informationen aus Word Tabellen zu extrahieren und dabei fiel mir auf, dass der Textstring immer mit chr(13)+chr(7) endet.
Ist das normal ?
Hier mal mein Programm, das insoweit zu funktionieren scheint:
Code: Alles auswählen
#include "activex.ch"
PROCEDURE main
LOCAL cDir,cFile,t,nZei,nSpa, cTxt
LOCAL oWord,oDoc,oTable,oCell,nAnzTables,nAnzColumns, nAnzRows
cls
cDir := CurDrive()+":\"+CurDir()
cFile := cDir +"\Test.doc"
// Erzeugen einer ActiveX-Komponente
oWord := CreateObject("Word.Application")
IF Empty( oWord )
MsgBox( "Microsoft Word ist nicht installiert" )
ENDIF
oWord:visible := .f.
oWord:documents:open( cFile )
oDoc := oWord:ActiveDocument
set alternate to WordInfo.txt
set alternate on
? "Dokument Info"
?
? "Datei: "+cFile
? "oDoc: "
?? oDoc
? "Anzahl der Tabellen ermitteln ... "
nAnzTables := oDoc:tables:count
? "Es gibt",nAnzTables,"Tabellen"
for t := 1 to nAnzTables
oTable := oDoc:tables(t)
? "Infos über Tabelle",t
nAnzColumns := oTable:columns:count
nAnzRows := oTable:rows:count
? "Anzahl der Spalten:",nAnzColumns
? "Anzahl der Zeilen: ",nAnzRows
for nZei := 1 to nAnzRows
for nSpa := 1 to nAnzColumns
? "Zeile"+str(nZei,2)+" Spalte"+str(nSpa,2)+" Inhalt: "
oCell := oTable:Cell(nZei,nSpa):range
cTxt := oCell:text
cTxt := strTran(cTxt,chr(13),"|")
cTxt := strTran(cTxt,chr(7),"~")
?? cTxt // -> "Zeile x, Spalte y |~"
next
next
next
oDoc:close()
oWord:Quit()
oWord:destroy()
inkey(10)
RETURN