mikej28621, I am sorry, but...
VBA can open the file, search for the text to be replace, add the lines you want, then save the file without it having to be opened.
If I walk through the steps -
1. VBA can open the file
2. Search for text
3. Adds the lines
4. Saves the file......without opening it.
Uh, please see #1.
VBA can not do anything to the internal parts of a file without opening it. If I am incorrect on this, please do post some code that shows how that could be done.
eHanDolo, simply put, HTM (or HTML) files are text files, nothing more, nothing less.
There are two ways to do what you want.
You can use filehandles and access the file, then use Write add your lines.
I would not recommend this method, unless you learn how to do FileI/O. It requires very specific line identification. But it can be done, and speed wise, is very likely the fastest. It can be done using VBA, but sorry, it still opens the file.
The second way is to open the HTM file in Word. Frankly, opening it in NotePad and copying it to WEord is not a bad idea. The reason being is that Word, as much as Microsoft would like to think of it as an HTML editor, is very very poor as an HTML editor. It is far better to add your line to a straight text file, then name the file HTM.
However, you can force Word to open the file as text.
If they are all in the same folder, look up using the Dir function to get all the files.
If you know where you line to add will go, and it is possible to do a search for the proceding line, that would be the way to go.
I can not give any more details as you would need to supply more details from your end. For example:
Is the line to be added always the same text?
Is it always the same relative location?
Say, you wanted to add a single line of a metatag to a bunch of htm files.
You would open the file.
search for a previous <META and move the cursor back (or maybe forward), insert your line, save the file as text...and go on to the next file.
It certainly is very do-able, but you have to open the files, one by one.
Gerry