Hi to all
I need a little example to how to read the line (txt) of a word doc, line by line
I need it because there are some informations inside thay i have to manipulate
PS: i know how to wrinte txt in word doc, but i dont know how to read it !!
Grazie
How read lines of word doc
Re: How read lines of word doc
The following example reads word contents, paragraph wise. Not sure whether this is what you are looking for. Maybe you can modify the code to suit your requirement
Code: Select all
#Include "Fivewin.ch"
*---------------------------*
Function Main()
Local oWord,oDoc,cWordFileName,aData, oPara
cWordFileName:="D:\Test.Doc"
oWord := CreateObject("Word.Application")
oWord:DisplayAlerts := 0
oDoc := oWord:Documents:Open(cWordFileName) //Open the word document
aData:={}
For Each oPara In oDoc:Paragraphs
aAdd( aData, oPara:Range:Text )
Next oPara
oDoc:Close()
oWord:Quit()
xBrowser aData
Return
Re: How read lines of word doc
Hi,
anserkk's solution when the Mic. Word is installed.
If it is not installed. there is a long solution.
1. rename file extention to zip. (eg. myfile.docx to myfile.zip)
2. unzip the zip file using hb_unzip() function.
3. there are several xml files in unzipped directory. find the xml file that is your information is looking for. and read xml file.
anserkk's solution when the Mic. Word is installed.
If it is not installed. there is a long solution.
1. rename file extention to zip. (eg. myfile.docx to myfile.zip)
2. unzip the zip file using hb_unzip() function.
3. there are several xml files in unzipped directory. find the xml file that is your information is looking for. and read xml file.
Last edited by Horizon on Wed Feb 24, 2021 9:39 am, edited 1 time in total.
Regards,
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
- MarcoBoschi
- Posts: 925
- Joined: Thu Nov 17, 2005 11:08 am
- Location: Padova - Italy
- Contact:
Re: How read lines of word doc
Great the solution of "anserkk"
It works
I will use it and start my work
Many thanks
It works
I will use it and start my work
Many thanks
- ryugarai27
- Posts: 65
- Joined: Fri Feb 13, 2009 12:03 pm
- Location: Manila, Philippines
- Contact:
Re: How read lines of word doc
Hi Anser,
Great work!
Is there also a way to get the words with emphasis? For example, I want to enclose all italic words in <italic>italic word</italic> and bold words in <bold>bold word</bold>.
Many thanks,
ryu ( FWH1706 + xHB1.0 + Pelles C + VS Code)
Great work!
Is there also a way to get the words with emphasis? For example, I want to enclose all italic words in <italic>italic word</italic> and bold words in <bold>bold word</bold>.
Many thanks,
ryu ( FWH1706 + xHB1.0 + Pelles C + VS Code)
Re: How read lines of word doc
Grazie to anserkk
But now i need to extract lines (or paragraphs) from a word file and write them in another files
By using the anserkk example i get only text without color, bold, formatting
Any suggestion
Grazie
But now i need to extract lines (or paragraphs) from a word file and write them in another files
By using the anserkk example i get only text without color, bold, formatting
Any suggestion
Grazie