Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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!.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
When i open excel file it takes time to open Muraliraj Menon Excel Discussion (Misc queries) 1 May 23rd 07 12:50 PM
Can Excel open a new application every time you open a file? shoon Setting up and Configuration of Excel 0 December 13th 05 03:28 PM
How do I stop Excel from closing the open file each time I open a. Welsin Setting up and Configuration of Excel 3 January 8th 05 11:16 PM
Desktop shortcut to a named Excel file - every time I open it adds a "1" to the file name - how to disable? [email protected] Setting up and Configuration of Excel 2 November 27th 04 09:02 PM
Excel VBA - open text file, replace text, save file? Cybert Excel Programming 2 October 2nd 04 01:05 AM


All times are GMT +1. The time now is 07:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"