[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Programatically add section of records in a text file

Posted on 2012-09-04
3
Medium Priority
?
662 Views
Last Modified: 2012-09-05
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
Comment
Question by:66chawger
  • 2
3 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 38365748
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
 

Author Comment

by:66chawger
ID: 38367754
So simple... forget sometimes how much you can do with find and replace.
0
 

Author Closing Comment

by:66chawger
ID: 38367755
Simple solution.  Worked great!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question