How to open a word document and search for specfic text?

I know how this works in Word VBA, but I'm not sure how to do it in VB .Net. Are Word VBA macro keywords and synatx portable to VB .Net? Basically, I have 20 to 30 page word document that I want to search for specfic text that a user would supply on a form using a text box and commandbutton.
Richard KreidlSoftware DeveloperAsked:
Who is Participating?
armoghanConnect With a Mentor Commented:
You need to add the Com reference of MS Word
see the following article for it

and then when you have the Active Document Object you can search it even without displaying it.

The link mentioned by tusharashah will work for VB.NET as well. see other related links at the bottom
also see
Check out this Article related to Search for Text in Word Document on MSDN:

Richard KreidlSoftware DeveloperAuthor Commented:
I saw that article, isn't that for VB 6.0? And don't you have to open and read a word document before you can search it?
This will find and replace  a string

Dim bFound As Boolean

    With Selection.Find
        .Text = "s"
        .Replacement.Text = "b"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
   bFound = Selection.Find.Execute(, , , , , , , , , , 2)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.