Forum Moderators: open

Message Too Old, No Replies

Find And Replace (More In Depth)

looking for some help on a script

         

YuryDRC

3:56 pm on Jun 11, 2007 (gmt 0)

10+ Year Member



Hello all, my name is Yury and i do some general coding here and there when i have large tasks and want to finish them quicker!

I tried searching through the site and google for many many Find and replace scripts in both VB and Javascript.

Basically This is what im looking for, and if ANYONE could provide ANY help i would greatly appreciate it. At least point me in the right direction to start.

Im looking to write a general find and replace script, and here is what i want it to do...

I have top100.xls which is a spreadsheet with the top 100 cities in California sorted by population.

I have an html File where I have "Los Angeles" as the header, lets call it variable X.

What im looking to do is have this script is take every city (1-100) in the list, replace variable X with that city name, and save (output/write) it as X.htm

Again, any help appreciated

mattur

11:32 am on Jun 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't say whether this is running on a website or locally, or the platform you're using so I'll assume you're looking to write a local VBScript/Javascript using WSH on your PC.

Look into the FileSystemObject - it enables you to save and load text files. So your script would be something like:

1. Open Excel file using ADO.
2. Load your prepared HTML template, with delimiters (eg *cityname*) where you want to insert the city name, using FileSystemObject.
3. Loop through each Excel row, do a simple replace on the *cityname* in the template text, and then save the result as cityname.htm using FileSystemObject.

HTH