Re: How to Search in MS Word using VBA

From: Doug Robbins - Word MVP (dkr_at_NOmvpsSPAM.org)
Date: 05/27/04


Date: Fri, 28 May 2004 08:50:48 +1000

I believe that the vba end of it is possible. You can get some clues from
the article "Find & ReplaceAll on a batch of documents in the same folder"
at:

http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

If the text is found in a document, you would set a Range object to say the
.Range of the first paragraph of the document, and then using the default
.Text property of that range, you would have the text to display on your
form. You can use the .FullName property of the document object to get the
path\filename of the document for your hyperlink and then when the user
wants to go to the text in a particular document, you could use Instr() on
the .Range of the document to get the location where the text was found and
then collapse a Range object to that location and then select the Range to
display the text.

If might actually be better to use Instr() in the first instance rather than
an Edit>Find though the latter may be quicker.

-- 
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested.  Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Ashish Kanoongo" <ashishk@armour.com> wrote in message
news:%23d%232cKAREHA.1396@TK2MSFTNGP12.phx.gbl...
I would to create a ASP base search utility. In this asp page user enter his
text in TEXT box,  then like to search, this search string in all the word
documents of particular folder. Then display a list of search result with
highlighted text first  2-3 line of all those word document where this
search is exist. Once user click any of the search result url, it will open
word document and directly jump to selected page/text.
Is it possible or not?  If yes let me guide in this matter. I know I can use
index server, but the problem is that it is not jump to particular page of
Word document where search is exist. If anyone help me in this matter, I can
go for Index server options also.
I will be thankful in advance in reagrds any kind of help.
Ashish
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 05/22/2004


Relevant Pages

  • Re: How to Search in MS Word using VBA
    ... If the text is found in a document, you would set a Range object to say the ... you would have the text to display on your ... word document and directly jump to selected page/text. ... go for Index server options also. ...
    (microsoft.public.word.vba.general)
  • Re: How to Search in MS Word using VBA
    ... If the text is found in a document, you would set a Range object to say the ... you would have the text to display on your ... word document and directly jump to selected page/text. ... go for Index server options also. ...
    (microsoft.public.word.conversions)
  • Re: Word Macro Problem
    ... I have an application from where I open Word document on the ... Now Use of macros starts from here. ... write function to access data from MS-Access. ... Thing I have to do is to display that data in word document. ...
    (microsoft.public.word.vba.beginners)
  • Re: Word Macro Problem
    ... I have an application from where I open Word document on the ... Now Use of macros starts from here. ... write function to access data from MS-Access. ... Thing I have to do is to display that data in word document. ...
    (microsoft.public.word.vba.beginners)
  • Re: Changing how linked objects (Excel) are displayed in Word.
    ... that the size of Excel sheet objects is ... How do you insert these linked objects? ... displayed in the Word document. ... When I attempt to revise the display, ...
    (microsoft.public.word.pagelayout)