mrmagoo_83
Board Regular
- Joined
- Mar 7, 2005
- Messages
- 82
I need some help. I have tried to do this on my own using other examples, but I am a bit lost.
I have a sheet in my excel file, a lot of data in column 1. I am wanting to open a text file and write all that data to that text file.
Each line in the column is like "The letter is", the macro adds a charater, so the column then looks like "The letter is A", then B, then C, etc...
I want to write the entire column to a text file such as A.txt (when everything is A) and B.txt when everything is (B).
I have the macro to run through and edit each line and all that; however, I cannot get this thing to open a file for nothing.
I tried the following, where the Filename was a variable that ends up looking like "C:\A.txt"; but i get an error 438 on the line that attempts to open the text file. Line is also a string Variable that has already been set to a value.
Can anyone help?
I have a sheet in my excel file, a lot of data in column 1. I am wanting to open a text file and write all that data to that text file.
Each line in the column is like "The letter is", the macro adds a charater, so the column then looks like "The letter is A", then B, then C, etc...
I want to write the entire column to a text file such as A.txt (when everything is A) and B.txt when everything is (B).
I have the macro to run through and edit each line and all that; however, I cannot get this thing to open a file for nothing.
I tried the following, where the Filename was a variable that ends up looking like "C:\A.txt"; but i get an error 438 on the line that attempts to open the text file. Line is also a string Variable that has already been set to a value.
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(Filename)
Set ts = f.OpenAsTextFile(ForAppending, TristateTrue)
ts.Write Line
ts.Close
Can anyone help?