Opening Text Files and Re-Saving Them

Opening Text Files and Re-Saving Them

Post by Qm9SZWQ3O » Sat, 13 Mar 2010 23:03:01


I am trying to write some code which will allow a user to select a folder
and then will open all of the text files in that folder and re-save them as
excel files.

I have sorted out the code to enable the user to select the folder they wish
to use, but am looking some assistance on the looping to enable each of the
text files to be opened and re-saved.

Can anyone suggest how I might do this.


Opening Text Files and Re-Saving Them

Post by Dave Peter » Sun, 14 Mar 2010 00:53:26

If the text files are all the same, you could record a macro that Opens, saves
as an excel file, and closes the file.

Then that recorded macro could be modified to open all the text files in the

If the files vary in format, then maybe you could have different macros for each
type of text file.

Ron de Bruin has some code for working with CSV files that may be a good
starting point:
(look for CSV)

If you need help tweaking your code, post back with your code and the version of
excel you're using--and the type of excel file you want to saveas.


Dave Peterson