Exporting fixed width text files

G

Guest

In a previous message I asked how to import a text file with mixed formats.
Now I need to export fixed width data files to a single text file. I have
been able to export the files, but I really need to export them and append
them in a single file. I haven't found an argument in the TransferText method
or the OutputTo action that lets me append to an existing file. As a work
around I have been exporting to multiple files and then using a word macro to
insert the files into a single document and save it as text. There must be a
better way. Thanks in advance for any suggestions.
 
J

John Nurick

One simple way is to export to two files and then shell to the Windows
COPY command to concatenate them. Assuming the files' names and
locations are in a pair of variables, something like this should do it:

strFileOut = "C:\My Folder\subfolder\output.txt"
Shell("COPY """ & strFile1 & """ + """ & strFile2 _
& """ """ & strFileOut & """", vbMinimizedNoFocus)

All those quote marks are to ensure that the filepecs, which may contain
spaces, are enclosed in quotes in the string that is passed to Shell.
 
G

Guest

That didn't work, I kept getiing a File not found error. So I created a batch
file with the copy command inside and used the shell command to run it. That
seems to do the trick. Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top