in message : : > I have about 200 documents to which I need to write a header and a
footer.
: > Appending (the footer) is easy, but I cannot figure out how to write to
: the
: > very beginning of the file. Any help would be appreciated
:
: Your "documents", I gather, are text files and not MS-Word documents.
:
: You'll have to "rewrite" to entire text file.
:
: Use the ReadAll method to read the intial file then write your header,
: the initial file, and the footer to the same file.
If you were going to do that, wouldn't this be easier?
sub appendit(file1, file2, file3, t)
dim fso, temp, tempFile, wshShell, oExec
set fso = CreateObject("Scripting.FileSystemObject")
set wshShell = CreateObject("WScript.Shell")
if fso.FileExists(file1) then
if fso.FileExists(file2) then
if fso.FileExists(file3) then
temp = fso.GetTempName
set oExec = wshShell.Exec("%comspec% /c copy " & file1 & "+" & file2
& "+" & file3 & " " & temp)
do while oExec.status = 0
wscript.sleep 100
loop
if fso.FileExists(t) then
fso.DeleteFile(t)
end if
fso.MoveFile temp, t
end if
end if
end if
wscript.echo temp
end sub
appendit "f1.txt","f2.txt","f3.txt","f4.txt"
f4.txt would be replace with the file you wanted to end up with, however, I
wouldn't use this for XML files.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library -
http://msdn.microsoft.com/library/default.asp