Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Webbrowser and find ...

Posted on 2002-03-20
8
Medium Priority
?
231 Views
Last Modified: 2010-05-02
Hi!

I have a embedded Webbrowser and it's showing a HTML file. I have textbox and a OK Button in top of the HTML form. If i press the OK Button it should search for the text (which is in the textbox) and go to this "line". Is this possible?

Falke
0
Comment
Question by:Falke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6883055
yes, it is possible.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6883093
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 400 total points
ID: 6883097
if you don't want to spend a penny:

Well you need to set references to microsoft html object library.
I have added one textbox to type text to serach and a command button to do the search. Webbrowser control's
name is wb1.


Option Explicit

Private Sub Command1_Click()
Dim ieDoc As HTMLDocument
   Set ieDoc = wb1.Document
   With ieDoc
       Dim TxtRng As IHTMLTxtRange
       Set TxtRng = .body.createTextRange
       If TxtRng.findText(Text1.Text) = True Then
           TxtRng.Select
           TxtRng.ScrollIntoView True
       Else
           MsgBox "Text not found", vbInformation, App.EXEName
       End If
   End With
End Sub

Private Sub Form_Load()
wb1.navigate "www.experts-exchange.com"
End Sub


Private Sub wb1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is wb1.Object) Then
   Command1.Enabled = True
Else
   Command1.Enabled = False
End If
End Sub

Hope it helps
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6884822
Here's one that is a bit of an upgrade on the one Ritchie posted (although I would guess that they are based on the same original sample)  -  :-)

This for if you want the full functionality (i.e. up/down, match case and full word only).

It needs:
-  A text box called txtFindTerm
-  A command button called cmdFind
-  two option buttons, optDown - "search down" and optUp - "search up" (in a frame)
-  Two check boxes, chkWholeWord - "Search whole word only" and chkCase - "Match case".

And there is a public variable called wbrDocument that is set to the document property of your webbrowser.

<general declarations>
Public wbrDocument As MSHTML.HTMLDocument
Private rngTextRange As IHTMLTxtRange

Private Sub cmdFind_Click()
  Dim intFlags As Integer
  Dim lngDirection As Long
 
  If Len(txtFindTerm.Text) > 0 Then
    If rngTextRange Is Nothing Then
      Set rngTextRange = wbrDocument.body.createTextRange
    End If
   
    With rngTextRange
      intFlags = 0
      If chkWholeWord.Value = vbChecked Then
        intFlags = intFlags + 2
      End If
      If chkCase.Value = vbChecked Then
        intFlags = intFlags + 4
      End If
     
      If optDown.Value = True Then
        lngDirection = 65535
        .moveStart "character", 1
        .moveEnd "character", 1
      Else
        lngDirection = -65535
        .moveStart "character", -1
        .moveEnd "character", -1
      End If
         
     
      If .FindText(txtFindTerm.Text, lngDirection, intFlags) = True Then
        .Select
        .scrollIntoView True
      Else
        MsgBox "Finished searching this page.", vbExclamation
      End If
     
    End With
  End If
 
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6885302
Anthony, to tell you the true, i figured it by myself.
0
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6887164
Must be a case of covergent evolution :-)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6887549
When i posted code, sure is mine otherwise post the link or at least, a mention to real author.
Sometimes, there are few ways to get things to work.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6903364
Thanks for "A" grade!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question