VB code to read word document
I want to search a word in a doc file or excel sheet. How can i do it. I have
done it in text file using the code
sFilepath = "c:\work\abc.txt"
fileno = FreeFile
Open sFilepath For Input As fileno
While Not (EOF(fileno))
Line Input #fileno, sStr
If StrComp(sStr, sKeyword) = 0 Then
present = True
Re: VB code to read word document
A word document is an OLE Structured storage document.
You can't treat it like a text file.
You can read the properties of a word document without opening it in word.
However to search for a specific word, you would have to know the binary file format
and how to manipulate it.
Or you would have to open it in word.
If you try using
Dim docTemp as Word.Document
Set docTemp = GetObject("filenamehere")
You may open a non-visible document.
Will Rickards ~ http://www.willrickards.net
Please reply only to newsgroup ~ Use of any info/code provided is at your own risk
"Arvind Sharma" <firstname.lastname@example.org> wrote in message news:email@example.com...
> I want to search a word in a doc file or excel sheet. How can i do it. I have
> done it in text file using the code
> sFilepath = "c:\work\abc.txt"
> fileno = FreeFile
> Open sFilepath For Input As fileno
> While Not (EOF(fileno))
> Line Input #fileno, sStr
> If StrComp(sStr, sKeyword) = 0 Then
> present = True
> End If
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center