Actually snb I know the first method (the second I did not) however I have avoided the first method and I will explain why. It may be irrelevant with a text file however with word files I have used similar coding to read word documents in one go using scripting dictionary. The problems I have encountered has to do with file encoding. So for example
The problem I run into has been due to OLE objects - with word documents perhaps created in other programs or older versions of Word I find sometimes I run into word tying up the OLE object due to the file encoding - it will halt excel and wait for an input from the user to select the type of encoding (eg. Windows Default, Western European etc etc) so the code can then read the file. With text files I have not played around with reading in one go. Have you had any problems with encoding in text documents reading them like you have demonstrated above with your first example?
Due to the OLE conflict I tend to read text files as I did with the code I posted and I don't have any problems. Using your second example is essentially what I have done except with a lot more code so I could certainly adopt your second method rather than line by line however for my own edification have you run into any problems as I have described using scripting fso reading text documents?
My guess would be that encoding is probably not a problem with text files however due to technical difficulties I have had with word objects I have tended to steer away from your first example when I have to read hundreds of documents (or when I am unsure how the text file has been generated) due to problems with differences between files due to the possibility of file encoding problems. For example I may get hundreds of documents from multiple sources so they are generated by many different programs/methods. Essentially what I am asking is in your vast experience have you run into problems with TEXT documents reading them with your first code example above? This is mainly for my own edification. Can your first example run into problems with encoding problems with multiple text documents.
I will certainly adopt your second method due to the succinct coding however I am interested in your comments with your first code example when dealing with multiple text documents or text documents potentially generated by many different methods.
I hope this makes sense and look forward to your experience.
PS: What's up with your Avatar?
Bookmarks