VB search and replace a string in a htlm file

Hi all, I need to open a html file and replace string "</BODY></HTML>" with ""..  When you open a normal html file you don't see the code, do you have to open it as a binary file??

Thanks in advance..

Kind regards,

Derek.
DelboyAsked:
Who is Participating?
 
List244Connect With a Mentor Commented:
What do you mean when you open a normal file you don't see the code?

This should work:

Dim HTMFILE as string
Open "FILENAME" for binary as #1
   HTMFILE = Space(Lof(1))
   Get #1,, HTMFILE
Close #1
HTMFILE = Replace(HTMFILE,"</BODY></HTML>","")
Kill "FILENAME"
Open "FILENAME" for binary as #1
   Put #1,, HTMFILE
Close #1
0
 
List244Commented:
If it is not supposed to be case sensitive:

HTMFILE = Replace(HTMFILE, "</BODY></HTML>", "", , , vbTextCompare)
0
 
DelboyAuthor Commented:
Hi ..  I meant if you aopen a html file to view, you don't see the html code, and only the text ..  but you have answered my query with your fab code..  works a treat..

Kind regards,


Derek.
0
 
List244Commented:
Glad I could help.
0
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.