VB code to read word document


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: VB code to read word document

Hybrid View

  1. #1
    Arvind Sharma Guest

    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
    End If
    Wend


  2. #2
    Will Rickards Guest

    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.
    See: http://support.microsoft.com/support.../Q224/3/51.ASP
    However to search for a specific word, you would have to know the binary file format
    and how to manipulate it.
    http://www.wotsit.org/download.asp?f=wword8
    http://www.wotsit.org/download.asp?f=word8

    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" <arvinds@mahindrabt.com> wrote in message news:39a5fbfa$1@news.devx.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
    > Wend
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center