Hi Guys
I'm trying to edit the recent updated file in a certain directory.(Remove blanks, Remove line containing "-" in a certain position)
So fare I have this but this only remove blanks in a certain file.
Sub RemoveBlanks()
Dim Filename As String
Const ForReading = 1
Const ForWriting = 2
Filename = Worksheets("Sheet1").Range("B2").Value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(Filename, ForReading)
Do Until objFile.AtEndOfStream
strline = objFile.Readline
strline = Trim(strline)
If Len(strline) > 0 Then
strNewContents = strNewContents & strline & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile(Filename, ForWriting)
objFile.Write strNewContents
objFile.Close
End Sub
Hope you guys can lead me on the right track
I'm trying to edit the recent updated file in a certain directory.(Remove blanks, Remove line containing "-" in a certain position)
So fare I have this but this only remove blanks in a certain file.
Sub RemoveBlanks()
Dim Filename As String
Const ForReading = 1
Const ForWriting = 2
Filename = Worksheets("Sheet1").Range("B2").Value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(Filename, ForReading)
Do Until objFile.AtEndOfStream
strline = objFile.Readline
strline = Trim(strline)
If Len(strline) > 0 Then
strNewContents = strNewContents & strline & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile(Filename, ForWriting)
objFile.Write strNewContents
objFile.Close
End Sub
Hope you guys can lead me on the right track