2007 Macro for repairing comma separated issue

B

BobJustBob

I upgraded from Word 2003/XP to Word 2007/Win7-64bit recently and los
the macros associated with the old installation. I have been able t
recreate all but one. Need help with this one, as it is too complicate
for me to create.
The files I need the macro for consist of several hundred lines o
comma delimited items, each item has double quotes around them, and th
end of each line has a <CR>.
The problem: I need to open this data in Word and make a correction t
the "," separation issue that is caused by the database that supplie
the data.
Notes: The first item on each line is fixed in length (8 number
enclosed in quotes) followed by the comma separator. The 2nd item is th
one with the issue - a NAME field. If the name field contains 2
characters or less - no problem; AFTER the name and before the DAT
field that follows, the normal "," pattern is there (there are example
of these below) followed by the date enclosed in quotes. If the nam
field contains 23 characters, the "," drops one character and become
just NAME",DATE - missing the second quote. If the name field contain
24 characters, the "," drops another character and appears as jus
NAME"DATE. If the field contains 25 characters (the maximum in any of m
data), the "," drops yet another character and appears as NAMEDATE wit
nothing separating them.
Samples (fake data):

"01388357","EVARADO STEFFHANIE RAE","10/26/12","3341"," . . . {Goo
Example, 22 characters in name}
"01389222","TENCCHEZ ROBENICE CLARI",10/24/12","1046"," . . . {2
chars, dropped the " before the date}
"01388214","ABC TRUCKING COMPANY INC"10/26/12","0120"," . . . {2
chars, dropped the ," before the date}
"01388220","CARONS CARTHAN SERVICE LL10/26/12","3341"," . . . {2
chars, dropped the entire "," separator}

I didn't write the lost macro from Word 2003, but am trying to recreat
the solution in Word 2007 now. I would imagine a macro that moved pas
the first 12 characters and looked for a "," would be a good approach
If the "," was there after the 12th position of each line, before i
reached a number 0-9, then it could move to the next line. If there wa
a " or , after the 12th position and it didn't follow the pattern ",
then the macro could insert the missing separator component(s), i.e
change a ", into "," | change " to "," | insert a "," between the NAM
and DATE when the 40th character is a / - (the / in the date) as thi
would be the only time the entire "," is missing.

Of course there are probably other methods for cleaning up my data, bu
this one strikes me as an efficient one, as it can skip many lines o
correct data. My data usually has 300 or so lines of data and mayb
10-15 are afflicted with the incorrect format of the "," pattern.

Any and all assistance with this would be greatly appreciated! I don'
have much experience with macros in Word, but have been able to fin
examples for my other macros that were similar enough to what I neede
to adjust and recreate those.

Thanks in advance,
Bo
 

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