ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA - Deleting Small Text Files (https://www.excelbanter.com/excel-programming/349283-vba-deleting-small-text-files.html)

ajocius[_48_]

VBA - Deleting Small Text Files
 

Group,
I'm not sure if I should break this up or just ask for the whole
enchilada. I'll start with the big picture. I want to launch a macro
that will review all text files in a directory. If the file is <= 500
bytes, delete it. If its greater than 500 bytes, starting parsing the
file. I want to have a single file, lets call it the master file
(Excel) which will take parts of the text file(s) and log what is being
copied from the text file. So my questions a
1. Can I delete files from within a spreadsheet? If so, how can I
do it?
2. Can I append to an Excel file based on data found in multiple
text files, each with a different name and potentially 1000's of text
files?

We test radios and each radio has a unique data file. The data is
saved in text with each file having a unique name to it. I want to
combine all the files into a master file. Later we analyize the data.
Your thoughts on how I should approach this macro. I want to do this
in VBA for Excel.

Tony


--
ajocius
------------------------------------------------------------------------
ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=497295


gajendra_vba[_6_]

VBA - Deleting Small Text Files
 

Answer for your questions are here..
1. Yeah, you can delete a file from within a spreadsheet using 'Kil
filepath( you want to delete)'.
2. Yes, you can append the text files by copying and pasting them in
spread sheet. For doing it perform these steps.
A. Add Microsoft Scripting Runtime reference to your project.
B. Use FileSystemObject form it.
C. By Using Collections i.e For Each File in Directory, open each tex
file, delemit the text, copy it and paste to your spreadsheet

--
gajendra_vb
-----------------------------------------------------------------------
gajendra_vba's Profile: http://www.excelforum.com/member.php...fo&userid=2993
View this thread: http://www.excelforum.com/showthread.php?threadid=49729


Dave Peterson

VBA - Deleting Small Text Files
 
If your .txt files are all in a single folder (and there's no .txt files that
shouldn't be merged together), maybe you could use Ron de Bruin's code:

http://www.rondebruin.nl/csv.htm

It actually looks for .csv files, but you could change that to .txt.

ajocius wrote:

Group,
I'm not sure if I should break this up or just ask for the whole
enchilada. I'll start with the big picture. I want to launch a macro
that will review all text files in a directory. If the file is <= 500
bytes, delete it. If its greater than 500 bytes, starting parsing the
file. I want to have a single file, lets call it the master file
(Excel) which will take parts of the text file(s) and log what is being
copied from the text file. So my questions a
1. Can I delete files from within a spreadsheet? If so, how can I
do it?
2. Can I append to an Excel file based on data found in multiple
text files, each with a different name and potentially 1000's of text
files?

We test radios and each radio has a unique data file. The data is
saved in text with each file having a unique name to it. I want to
combine all the files into a master file. Later we analyize the data.
Your thoughts on how I should approach this macro. I want to do this
in VBA for Excel.

Tony

--
ajocius
------------------------------------------------------------------------
ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=497295


--

Dave Peterson


All times are GMT +1. The time now is 12:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com