• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 679
  • Last Modified:

Programatically add section of records in a text file

I have a text file that contains thousands of record sets.  For each of these record sets, the last record starts with SE*.

I want to programatically add several records directly before this record in each record set.  

Example: Here is an example of the the record set.  For record set A and B they both end with SE* Record.  I basically need to be able to add 4 additional records before each of the SE* Records.  The records to add are all the same.  So say in my VB macro I run in Word will need to find the first SE* Record, and add the 4 records above it (just call these New record 1, New Record 2, New Record 3....  Then loop through the rest of the file finding each of the remaining SE* Records and add the same 4 records as mentioned previosly.

Record 1a
Record 1b
Record 1c
Record 1d
New Record 1
New Record 2
New Record 3
New Record 4
SE* record
Record 2a
Record 2b
Record 2c
New Record 1
New Record 2
New Record 3
New Record 4
SE* record
:
:
:
0
66chawger
Asked:
66chawger
  • 2
1 Solution
 
Patrick MatthewsCommented:
You can do this without code.  Just open the file in Word, and use Find/Replace with this as the Find string:

SE* Record

and this as the Replace string:

New Record 1^pNew Record 2^pNew Record 3^pNew Record 4^pSE* Record
0
 
66chawgerAuthor Commented:
So simple... forget sometimes how much you can do with find and replace.
0
 
66chawgerAuthor Commented:
Simple solution.  Worked great!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now