[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

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.
0
Delboy
Asked:
Delboy
  • 3
1 Solution
 
List244Commented:
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now