L
Legacy 15162
Guest
I am trying to replace a variable amount of characters at the beginning of a line. for this example, the file as 32 characters at the beginning to be deleted. Here is my code as such. I keep getting the "object variable or with block variable not set" error at the specified location.
any help would be greatly appreciated.
Rich (BB code):
Public Function WebReport()
Dim i As Integer
Dim fso As New FileSystemObject
Dim folder As folder
Dim filename As String
Set folder = fso.GetFolder("c:\webreports")
For Each file In folder.Files
filename = fso.GetFileName(file)
Select Case True
Case InStr(1, filename, "CC_CSHAUD")
FormatReport filename, 32
End Select
Next file
End Function
Public Function FormatReport(filename As String, k)
Dim fso As FileSystemObject
Dim ts As TextStream
Dim tsvar As String
Set ts = fso.OpenTextFile(filename, ForAppending, True)
tsvar = ts.ReadLine()
While Not ts.AtEndOfStream
tsvar = ts.ReadLine()
tsvar = Replace(tsvar, Left(tsvar, k), "")
Wend
End Function
any help would be greatly appreciated.