swaggerbox
06-10-2009, 12:43 AM
I have multiple text files in C:\Test folder. Inside each text file are datasets that begins with <COVER> and ends with <ECOVER>. Both Cover and ECOVER tags have the same values.
I want to extract the values of all <COVER> and <EAC> in a LOG file that corresponds to the filename of the specific TXT file followed by LOG extension and count the number of datasets. For example, if C:\Test folder contains 2 TXT files, it should generate 2 LOG files. For this example, I used XXXX.TXT which contains three datasets with the following information:
<COVER> XXXXXXX-A
<MTM> 1
<WF> XXXXXX
<EAC> YYYY
<PP> 1
<ECOVER> XXXXXXX-A
<COVER> ZZZZZZZ-A
<MTM> 1
<WF> XXXXXX
<EAC> YYYY
<PP> 1
<ECOVER> ZZZZZZZ-A
<COVER> YYYYYYYY-A
<MTM> 1
<WF> XXXXXX
<EAC> YYYY
<PP> 1
<ECOVER> YYYYYYYY-A
This would generate XXXX.LET which has an output like the one shown below:
-----------------------------------------------------------------------
Please find the data of 3 files in this shipment.
Please find the data for the following files in XXXX.TXT
Cover ID. EAC ID.
========== ===========
XXXXXXX-A YYYY
ZZZZZZZ-A YYYY
YYYYYYYY-A YYYY
-----------------------------------------------------------------------
Is there a way I can do this using VBA?
I want to extract the values of all <COVER> and <EAC> in a LOG file that corresponds to the filename of the specific TXT file followed by LOG extension and count the number of datasets. For example, if C:\Test folder contains 2 TXT files, it should generate 2 LOG files. For this example, I used XXXX.TXT which contains three datasets with the following information:
<COVER> XXXXXXX-A
<MTM> 1
<WF> XXXXXX
<EAC> YYYY
<PP> 1
<ECOVER> XXXXXXX-A
<COVER> ZZZZZZZ-A
<MTM> 1
<WF> XXXXXX
<EAC> YYYY
<PP> 1
<ECOVER> ZZZZZZZ-A
<COVER> YYYYYYYY-A
<MTM> 1
<WF> XXXXXX
<EAC> YYYY
<PP> 1
<ECOVER> YYYYYYYY-A
This would generate XXXX.LET which has an output like the one shown below:
-----------------------------------------------------------------------
Please find the data of 3 files in this shipment.
Please find the data for the following files in XXXX.TXT
Cover ID. EAC ID.
========== ===========
XXXXXXX-A YYYY
ZZZZZZZ-A YYYY
YYYYYYYY-A YYYY
-----------------------------------------------------------------------
Is there a way I can do this using VBA?