-
I need some help for the following problem:
How can I change/add a certain content(i.e. Name of customer) in an existing HTML document via VB?
For example:
Dear ******** <--- Name of customer to be changed/added
We want to inform.......
The HTML files are pure HTML without META-Tags, without Java/Javascript.
Any input would be great.
-
Well having done vaguely this kind of thing before, I'd suggest that you find a recognisable point in your HTML file which you can use as a reference point to the place you have to insert your text. So, in this case, it might be the first instance of the string "Dear ". I'll assume this is the case from here, but if it's not you can figure something out I'm sure.
First read the whole file into a big string variable. Then you can use code that's something like this:
Code:
strHTML = Left(strHTML, InStr(strHTML, "Dear ")) & _
strCustomerName & _
Right(strHTML, Len(strHTML) - InStr(strHTML, "Dear ") + 1)
'now output strHTML to your customised HTML file.
That code has a lot of room for optimization if you're going to be doing this a lot.
-
How are you accessing the HTML from VB? <font color="#00007F">If</font> vb is a viewer then before you .Navigate to the browser you could read in the file (line input) and replace a custom tag.
[code]
open "C:\inetpub\test.html" for input as #1
do
line input #1,a$
if instr(a$,"<@NameTag>") then
a$=left$(a$,instr(a$,"<@NameTag>")-1) & strCustomerName & right$(instr(a$,"<@NameTag>")+10)
while not eof(1)
close #1
[\code]
if this helps......
-
:-)
Thanks a lot. This will do it.