ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   writing to txt files (https://www.excelbanter.com/excel-programming/284521-writing-txt-files.html)

mudraker[_55_]

writing to txt files
 

Open sFile(2) For Append As #1
To Append (add to the bottom of an existing text file

Open "C:\tempfolder\temp.txt" For Append As #

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements

Stuart[_12_]

writing to txt files
 
I am wanting to write to the end of an existing text file. the following
works however I am sure their is a better way. i.e. not having to open it
twice!!


Open "C:\tempfolder\temp.txt" For Input As #1
iData = ""
Do While Not EOF(1)
Line Input #1, textLine
iData = iData & textLine
Loop
Close #1

Open "C:\tempfolder\temp.txt" For Output As #1
Print #1, iData & Chr(10) & iHist
Close #1




All times are GMT +1. The time now is 03:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com