search a word in html file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veer
    New Member
    • Jul 2007
    • 198

    search a word in html file

    Hi!
    i am making a program in which i want to search a particular word in html file
    and if word found save it into excel file with html file name
    e.g
    i want to search a string "visual" in a.html file and if found then this string is transfered into excel file with html file name

    please give some idea
    thanks in advance
    varinder
  • VijaySofist
    New Member
    • Jun 2007
    • 107

    #2
    Hi varinder!

    You can Use the Instr function for this purpose.

    For Example Consider the following Example Code
    [CODE=vb]
    If InStr(1,YourHtm lFileContent, "visual" ,vbTextCompare) > 0 Then
    'Your Operational Code
    End If
    [/CODE]

    All The Best

    Thanks and Regards
    Vijay.R

    Comment

    • veer
      New Member
      • Jul 2007
      • 198

      #3
      Thanks for reply
      can i put my file name just like this

      If InStr(1,a.html, "visual" ,vbTextCompare) > 0 Then
      'Your Operational Code
      End If

      actually i don't want to open the file and show the contents
      actually i have a folder in which more than one files are stored and i want to search a single string in all the files




      Originally posted by VijaySofist
      Hi varinder!

      You can Use the Instr function for this purpose.

      For Example Consider the following Example Code
      [CODE=vb]
      If InStr(1,YourHtm lFileContent, "visual" ,vbTextCompare) > 0 Then
      'Your Operational Code
      End If
      [/CODE]

      All The Best

      Thanks and Regards
      Vijay.R

      Comment

      • VijaySofist
        New Member
        • Jun 2007
        • 107

        #4
        Originally posted by veer
        Thanks for reply
        can i put my file name just like this

        If InStr(1,a.html, "visual" ,vbTextCompare) > 0 Then
        'Your Operational Code
        End If

        actually i don't want to open the file and show the contents
        actually i have a folder in which more than one files are stored and i want to search a single string in all the files
        Hi!

        First Read the HTML file contents and Store it in a String VAriable. Then Substitute the String Variable in the above said code in place of "a.html"


        All The Best

        Thanks and Regards
        Vijay. R

        Comment

        • veer
          New Member
          • Jul 2007
          • 198

          #5
          thanks for reply
          can you give me some programing help and also i want to know is there any liberary refrence is required for opening html file like doc or excel file

          thanks in advance


          Originally posted by VijaySofist
          Hi!

          First Read the HTML file contents and Store it in a String VAriable. Then Substitute the String Variable in the above said code in place of "a.html"


          All The Best

          Thanks and Regards
          Vijay. R

          Comment

          • VijaySofist
            New Member
            • Jun 2007
            • 107

            #6
            Originally posted by veer
            thanks for reply
            can you give me some programing help and also i want to know is there any liberary refrence is required for opening html file like doc or excel file

            thanks in advance
            Hi veer!

            You can open a html file just like a text file.

            The Syntax for opening a text file is
            [CODE=vb]
            Dim CompContent as String
            CompContent = ""
            Open "D:\Test.ht ml" For Input As #1
            CompContent = Input$(LOF(1), #1)
            Close #1
            [/CODE]


            In the above example code Test.html is my File Name. You can use your file Name instead of my file name here(with your file path). Now the full Content of that file will be available in the CompContent variable

            All the Best

            Thanks and Regards
            Vijay.R

            Comment

            • veer
              New Member
              • Jul 2007
              • 198

              #7
              Hi
              it works but when special character like "ö,ä "come
              this programe does not works
              Originally posted by VijaySofist
              Hi veer!

              You can open a html file just like a text file.

              The Syntax for opening a text file is
              [CODE=vb]
              Dim CompContent as String
              CompContent = ""
              Open "D:\Test.ht ml" For Input As #1
              CompContent = Input$(LOF(1), #1)
              Close #1
              [/CODE]


              In the above example code Test.html is my File Name. You can use your file Name instead of my file name here(with your file path). Now the full Content of that file will be available in the CompContent variable

              All the Best

              Thanks and Regards
              Vijay.R

              Comment

              • VijaySofist
                New Member
                • Jun 2007
                • 107

                #8
                Originally posted by veer
                Hi
                it works but when special character like "ö,ä "come
                this programe does not works
                Hi Veer!

                For these type of problems, you can use some external Controls which reads the HTML File Content. For example there is a control named AllText Control which reads the HTML File Content as it is. Try those type of controls in your Project.

                All the Best

                With Regards
                Vijay. R

                Comment

                Working...