Greetings Again,
I am trying to streamline a bit more of my project.
What I am trying to do is to append 2 separate text files into a 3rd.
that 3rd file needs to be saved in 2 separate locations (Archived file and a user file)
So far I have been able to Append, and save to a single location but I cannot make it save to a second location after the first.
Now the H drive is a USB Jump Drive the user is supposed to insert before running the workbook.
I've had a few instances where the user forgot and it crashes. What would the simplest error handling be for this? Is there a small routine to confirm the existance of the H drive or ask the user to connect if its not there?
Now with the same event I need to be able to create an exact duplicate of the H:\Dig\userfile.txt in the C:\Dig\Archived\ directory.
Should I just replicate the code and change the output to the archived folder? or is there a quicker way to send the userfile.txt file to 2 separate folders at the same time?
Cheers
Lwrence
I am trying to streamline a bit more of my project.
What I am trying to do is to append 2 separate text files into a 3rd.
that 3rd file needs to be saved in 2 separate locations (Archived file and a user file)
So far I have been able to Append, and save to a single location but I cannot make it save to a second location after the first.
Code:
' looks for the operator selected file to append.
'
ChDir "C:\Dig\data\"
sFilename = Application.GetOpenFilename("Text Files (*.txt), *.txt")
' Recreates the user file to ensure its always blanks to start with
Set fs = CreateObject("Scripting.FileSystemObject")
Set u = fs.CreateTextFile("H:\Dig\userfile.txt", True)
u.WriteLine ("")
u.Close
'
' opens the blank file, then appends the operator selected file and the static file
Open "H:\Dig\userfile.txt" For Append As #1 'Open the file to be created
Open sFilename For Input As #2 'Open the file to be appended to
Open "C:\Dig\messages\get1.txt" For Input As #3 'Open the file to be appended
Print #1, Input(LOF(2), 2); 'Read in the second file appending it to the first
Print #1, Input(LOF(3), 3); 'Read in the third file appending it to the first
Close 1, 2, 3 'Close all files
End Sub
Now the H drive is a USB Jump Drive the user is supposed to insert before running the workbook.
I've had a few instances where the user forgot and it crashes. What would the simplest error handling be for this? Is there a small routine to confirm the existance of the H drive or ask the user to connect if its not there?
Now with the same event I need to be able to create an exact duplicate of the H:\Dig\userfile.txt in the C:\Dig\Archived\ directory.
Should I just replicate the code and change the output to the archived folder? or is there a quicker way to send the userfile.txt file to 2 separate folders at the same time?
Cheers
Lwrence