"Tom Lavedas" <tglbatch@newsgroup> wrote On May 11, 9:37 am
> <SNIP>
>This function has strKey hard coded into the function (see comment
> above).
Thanks for that Tom, silly mistake on my part.
I've removed that line, but it doesn't seem to have any real effect on the
script, it will still not remove x500 or SystemMailbox. Not sure what the
problem is, do I need to 'null' or 'destroy' any of the values or objects
created? (it's been a long time since I did anything beyond basic
scripting!)
Here's the modified script in full:
Option Explicit
Call DeleteLine("x400")
Call DeleteLine("x500")
Call DeleteLine("SystemMailbox")
Function DeleteLine(strKey)
Const ForReading=1:Const ForWriting=2
Dim objFSO,objFile,strLine,strLineCase,strNewFile,strFile,LineNumber
strFile = "C:\proxyaddresses.txt"
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile=objFSO.OpenTextFile(strFile,ForReading)
Do Until objFile.AtEndOfStream
strLine=objFile.Readline
If LineNumber=objFile.Line-1 or LineNumber=0 then
If instr(strLine,strKey) or instr(strLineCase,strkey) or strKey=""
then
strNewFile=strNewFile
Else
strNewFile=strNewFile&strLine&vbcrlf
End If
Else
strNewFile=strNewFile&strLine&vbcrlf
End If
Loop
objFile.Close
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFile=objFSO.OpenTextFile(strFile,ForWriting)
objFile.Write strNewFile
objFile.Close
Set objFile = Nothing
Set objFso = Nothing
Set strKey = Nothing
Exit Function
End Function
--
Aziz