N
Nicholas Charles
Apologies, but new to using INPUT and FileSystemObject
when i reference a MSword (.doc) file and/or some text (.txt) files using
INPUT or File System Object, it opens the whole contents as one string ie no
line feeds to seperate each row. how can i loop through each row ?
is this an issue to do with a linefeed break at end of each row ? or can
the text be split but some meansd of a charactor count and adding a line feed
first, then
Dim objFSO As FileSystemObject
Dim t As TextStream
Dim vEachLine
Dim sTempStr
Set objFSO = New FileSystemObject
Set t = objFSO.OpenTextFile(sFile, 1, False)
' does not like next line ?? (i found this code in a colleagues workbook)
vEachLine = Split(objFSO.OpenTextFile(sFile).ReadAll, vbCrLf)
' and if i use
While Not t.AtEndOfStream
Debug.Print ts.ReadLine
Wend
each 'line' is the tewxt in the whole document ?
the INPUT method ive also tried adapting is
hFile = FreeFile
Open sFILE For Input As #hFile
i = 0
j = 2
Do While Not EOF(hFile)
' code here
Loop
'close file
Close #hFile
' but this still as all contents in one string ??
Help, thanks
when i reference a MSword (.doc) file and/or some text (.txt) files using
INPUT or File System Object, it opens the whole contents as one string ie no
line feeds to seperate each row. how can i loop through each row ?
is this an issue to do with a linefeed break at end of each row ? or can
the text be split but some meansd of a charactor count and adding a line feed
first, then
Dim objFSO As FileSystemObject
Dim t As TextStream
Dim vEachLine
Dim sTempStr
Set objFSO = New FileSystemObject
Set t = objFSO.OpenTextFile(sFile, 1, False)
' does not like next line ?? (i found this code in a colleagues workbook)
vEachLine = Split(objFSO.OpenTextFile(sFile).ReadAll, vbCrLf)
' and if i use
While Not t.AtEndOfStream
Debug.Print ts.ReadLine
Wend
each 'line' is the tewxt in the whole document ?
the INPUT method ive also tried adapting is
hFile = FreeFile
Open sFILE For Input As #hFile
i = 0
j = 2
Do While Not EOF(hFile)
' code here
Loop
'close file
Close #hFile
' but this still as all contents in one string ??
Help, thanks