Hi there MP,
Thanks, that's great! One more question though, how can I replace a space with a linefeed?
I've tried using the Chr(10) thing but it doesn't seem to work.
Cheers,
Foss
----- Michel Pierron wrote: -----
Hi Foss,
If that can help you:
Sub UpDateTxtFile()
Dim FSO As Object, File As Object, Contents As String
Set FSO = CreateObject("Scripting.FileSystemObject")
' Create file to test example:
Set File = FSO.CreateTextFile("c:\examplefile.txt")
Contents = "A quick example of the ReadAll method !!!"
Contents = Contents & vbCrLf
Contents = Contents & "New line for this example !!!"
File.Write Contents
File.Close
' Replacement routine
Const TxtFullPath As String = "c:\examplefile.txt"
Dim ReadFile As Object
Set ReadFile = FSO.OpenTextFile(TxtFullPath, 1, False)
Contents = ReadFile.ReadAll
ReadFile.Close: Set ReadFile = Nothing
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = False
.Pattern = "[!" & vbCrLf & "]"
Contents = .Replace(Contents, "")
End With
Set File = FSO.CreateTextFile(TxtFullPath)
File.Write Contents
File.Close
Set File = Nothing: Set FSO = Nothing
End Sub
Regards,
MP
Foss said:
Mornin' all,
certain symbols with either nothing or a line return.
got some pointers or code that would help me?
Foss