![]() ![]() Other operating system may just need a LF (Chr$(10)). ![]() Note that input reads a LINE at a time so each line appended to sFinal needs to have a CR and LF appended at the end to be written out correctly on a MS Windows system. sFinal contains the complete text of the File ready to be written at one shot. Note you don't need to do a loop to write. Open "C:\Clients\Converter\2.txt" For Output As #iFileNo IFileNo = FreeFile 'Don't assume the last file number is free to use Open "C:\Clients\Converter\Clockings.mis" For Input As #iFileNo So when you go to write it out, all you are writing is the last line you read, which is probably a blank line. SFileText is a string variable so what is happening is that each time you read, you just replace the content of sFileText with the content of the line you just read. Then here you write it out Write #iFileNo, sFileText Set TS = FSO.OpenTextFile("C:\Clients\Converter\2.txt", ForWriting, True)Īs for what is wrong with your original code here you are reading each line of the text file. 'OR use this if you need to process each line 'Use this for reading everything in one shot Set TS = FSO.OpenTextFile("C:\Clients\Converter\Clockings.mis", ForReading) Then you can use this code which is way better than the default file commands Dim FSO As FileSystemObject Just go project Reference and check Microsoft Scripting Runtime and click OK. ![]() It far easier to use the scripting runtime which is installed by default on Windows
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |