I have in a dir c:\myfile\ many txt file.
Is possible to open one and append from the last free line a new data, save it, close and exit...
Thah is all
append data in txt file
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: append data in txt file
Sorry me... but this is a stupid question, i know well this method, tks Hans.HansV wrote:Do you want to append the same text to all files?
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: append data in txt file
YES i can make the code myself, tks for assitenceHansV wrote:So you'll work it out for yourself?
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: append data in txt file
sorry if i post on old th3d...HansV wrote:So you'll work it out for yourself?
but really no!
with command in CICS procedure i select many report (Are all a txt file) approx 10/12
from a similar loop for next in CICS command i send to c:\mydir\a.txt, c:\mydir\b.txt, c:\mydir\c.txt, ... ecc until the 12Th file is created.
The file are little dimension approx 900 kb
during the loop a need to append from the fist file saved, for example c:\mydir\a.txt, the subsequent other file...
example:
c:\mydir\a.txt is finished, append to the atxt the b.txt, the b.txt is finished append c.txt ecc...
note:
with a code i can test when the job of txt is finished
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: append data in txt file
You could use the following macro:
Call it like this:
AppendFiles "C:\MyDir\a.txt", "C:\MyDir\b.txt"
AppendFiles "C:\MyDir\a.txt", "C:\MyDir\c.txt"
...
Code: Select all
Sub AppendFiles(strFile1 As String, strFile2 As String)
' Run the DOS Copy command to append the text files.
Shell "command.com /c copy """ & strFile1 & """+""" & _
strFile2 & """ """ & strFile1 & """ /b"
End Sub
AppendFiles "C:\MyDir\a.txt", "C:\MyDir\b.txt"
AppendFiles "C:\MyDir\a.txt", "C:\MyDir\c.txt"
...
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: append data in txt file
OPS!!!HansV wrote:You could use the following macro:
Call it like this:Code: Select all
Sub AppendFiles(strFile1 As String, strFile2 As String) ' Run the DOS Copy command to append the text files. Shell "command.com /c copy """ & strFile1 & """+""" & _ strFile2 & """ """ & strFile1 & """ /b" End Sub
AppendFiles "C:\MyDir\a.txt", "C:\MyDir\b.txt"
AppendFiles "C:\MyDir\a.txt", "C:\MyDir\c.txt"
...
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: append data in txt file
Does this work?
Code: Select all
Sub AppendFiles(strFile1 As String, strFile2 As String)
' Run the DOS Copy command to append the text files.
Shell "cmd /c copy """ & strFile1 & """+""" & _
strFile2 & """ """ & strFile1 & """ /b"
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: append data in txt file
HansV wrote:Does this work?
Code: Select all
Sub AppendFiles(strFile1 As String, strFile2 As String) ' Run the DOS Copy command to append the text files. Shell "cmd /c copy """ & strFile1 & """+""" & _ strFile2 & """ """ & strFile1 & """ /b" End Sub
WORK PERFECT!!!!!!!!!!!!!!!!!!!!!
but if i'm wrong i have see for one sec a msdos windows, possible?
if yes possible to suppress?
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: append data in txt file
Try
Code: Select all
Sub AppendFiles(strFile1 As String, strFile2 As String)
' Run the DOS Copy command to append the text files.
Shell "cmd /c copy """ & strFile1 & """+""" & _
strFile2 & """ """ & strFile1 & """ /b", vbHide
End Sub
Best wishes,
Hans
Hans