Page 1 of 1 1
Topic Options
#96588 - 2002-12-03 05:41 PM Readline of a Word Doc.
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
This post prompted me of something..

> Word COM script from Shawn: http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=003254#000001

Is there a way to do a line-by-line read of a Word Document?

Did some searching on - http://www.mvps.org/word

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#96589 - 2002-12-03 05:44 PM Re: Readline of a Word Doc.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
something similar I had in mind when posted:
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=13;t=000352
_________________________
!

download KiXnet

Top
#96590 - 2002-12-03 06:34 PM Re: Readline of a Word Doc.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You would have to convert it first into another document format, e.g. with COM automation.
_________________________
There are two types of vessels, submarines and targets.

Top
#96591 - 2002-12-03 06:46 PM Re: Readline of a Word Doc.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Know you can grab a few lines of normally formatted text (fe not heading info) like this:

break on

$filename = "c:\test.doc"

$word = createobject("word.application")

if $word
 $= $word.documents.open("$filename")
 $text = $word.activedocument.content.text
 ?"text=$text"
 $word.quit
 $word = 0
endif

exit 1

-Shawn

[ 03. December 2002, 18:48: Message edited by: Shawn ]

Top
#96592 - 2002-12-03 07:11 PM Re: Readline of a Word Doc.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens, that conversion is the thing I want to avoid with using com to read doc file.
if given word the ability to convert the file, it's screwed up, no matter what the conversion is.
_________________________
!

download KiXnet

Top
#96593 - 2002-12-03 07:41 PM Re: Readline of a Word Doc.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Theres a com call to convert it to a textfile as well ... never tried so don't know what it looks like ... stfw should show the syntax.
Top
#96594 - 2002-12-04 06:27 PM Re: Readline of a Word Doc.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sorry shawn STFW did not give any results.
doing my way, MSDN library check (online msdn failed too)
_________________________
!

download KiXnet

Top
#96595 - 2002-12-04 06:33 PM Re: Readline of a Word Doc.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Lonkero: See http://www.wvware.com/
_________________________
There are two types of vessels, submarines and targets.

Top
#96596 - 2002-12-04 06:35 PM Re: Readline of a Word Doc.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens?
programs/libraries I see, help I no see.
_________________________
!

download KiXnet

Top
#96597 - 2002-12-04 06:45 PM Re: Readline of a Word Doc.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hmmm - how about this then:

$format = 8

$word.activedocument.saveas("c:\shawn.txt",$format)

where $format can be (amongst others):

5 - text
6 - rtf
8 - html

Top
#96598 - 2002-12-04 07:09 PM Re: Readline of a Word Doc.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
thanks shawn.
looks little simpler than from visual basic help:
code:
$documentObj.SaveAs(FileName,FileFormat,LockComments,Password,AddToRecentFiles,WritePassword,ReadOnlyRecommended,EmbedTrueTypeFonts,SaveNativePictureFormat,SaveFormsData,SaveAsAOCELetter)



[ 04. December 2002, 19:10: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#96599 - 2002-12-04 07:12 PM Re: Readline of a Word Doc.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
also found out that when word converts it's text to html, it destroys all tables and such.
but .converttotext you can specify how the conversion is done and tables are there...
_________________________
!

download KiXnet

Top
#96600 - 2002-12-05 02:13 PM Re: Readline of a Word Doc.
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Shawn,

Brilliant!

Works great..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#96601 - 2002-12-05 02:16 PM Re: Readline of a Word Doc.
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
For anybody who is interested..

code:
break on
$filename = "C:\TEST.DOC"

$word = createobject("word.application")

if $word
$= $word.documents.open("$filename")
$format = 5

$word.activedocument.saveas("c:\kent.txt",$format)

;where $format can be (amongst others):
;5 - text
;6 - rtf
;8 - html
$word.quit
$word = 0
endif

exit 1

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#96602 - 2002-12-05 03:53 PM Re: Readline of a Word Doc.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uhh...
yep, foundable in udf library under name of doc2txt()
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 995 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.069 seconds in which 0.027 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org