![]() |
In VBA How to Open two text file in same time?
Read data from one opened text file and write to another text file without
closing First text file. |
In VBA How to Open two text file in same time?
Depends what you want to do, but here's one example:
Private Sub CommandButton1_Click() Dim FileRead As Long Dim FileWrite As Long Dim TempStr As String Const ReadFileName As String = "C:\ReadText.txt" Const WriteFileName As String = "C:\WriteText.txt" FileRead = FreeFile Open ReadFileName For Input As #FileRead FileWrite = FreeFile Open WriteFileName For Output As #FileWrite 'Or maybe 'Open WriteFileName For Append As #FileWrite Do While Not EOF(FileRead) Input #FileRead, TempStr 'Do something with the string TempStr = "Read value: " & TempStr 'Write out Write #FileWrite, TempStr 'Or maybe use Print Loop Close #FileRead Close #FileWrite End Sub NickHK "Lotuxel" wrote in message ... Read data from one opened text file and write to another text file without closing First text file. |
In VBA How to Open two text file in same time?
"NickHK" wrote: Depends what you want to do, but here's one example: Private Sub CommandButton1_Click() Dim FileRead As Long Dim FileWrite As Long Dim TempStr As String Const ReadFileName As String = "C:\ReadText.txt" Const WriteFileName As String = "C:\WriteText.txt" FileRead = FreeFile Open ReadFileName For Input As #FileRead FileWrite = FreeFile Open WriteFileName For Output As #FileWrite 'Or maybe 'Open WriteFileName For Append As #FileWrite Do While Not EOF(FileRead) Input #FileRead, TempStr 'Do something with the string TempStr = "Read value: " & TempStr 'Write out Write #FileWrite, TempStr 'Or maybe use Print Loop Close #FileRead Close #FileWrite End Sub NickHK "Lotuxel" wrote in message ... Read data from one opened text file and write to another text file without closing First text file. Hi Nick HK, Thanks alot ! Great!. |
All times are GMT +1. The time now is 07:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com