opening text file with fixed widths already set


Posted by Jennifer on February 08, 2002 8:30 AM

I have a couple hundred text files that I need to open in a format so that the data is divided out in preset column widths. I have opened one file and gone in and set all the widths for it. Is there a way I can save the format of this file and open the other files so that they will have the same column widths without me having to go in and set them individually?

Posted by DK on February 08, 2002 8:55 AM

Hi,

If you record a macro for just one file and post the code I'll show you how to do it for a large number of different files.

Regards,
D

Posted by inmaps on February 08, 2002 9:56 AM

Could you save the file as a template and then just import the text files having opened the template (.xlt) as a document (.xls)

Bruce

Posted by Jennifer on February 08, 2002 10:17 AM

I thought about trying it this way and this may make me sound completely stupid, but I can't get it to start recording a macro until I have a file open and I can't open the file until I have set the widths in the text file. Does that make any sense?

Posted by Jennifer on February 08, 2002 10:19 AM

I saved the file I have fixed as a template, but when I have it open and I go to open the next one, it still comes up with the "text import wizard". What am I doing wrong?!?!?!??

Posted by Jennifer on February 08, 2002 10:19 AM

I saved the file I have fixed as a template, but when I have it open and I go to open the next one, it still comes up with the "text import wizard". What am I doing wrong?!?!?!??



Posted by DK on February 08, 2002 10:59 AM

Just add a new workbook and click Tools, Macro, Record New Macro. Then do everything you need to do for one file. When you've finished stop recording and then copy the code from the VB Editor. The code I'll be able to give you will allow your macro to operate on a load of files (e.g. all text files in a folder) but I can't do this until you've posted the code for one file. Without this, it's not possible to know the format you want the file in.

Regards,
D