Newbie: Changing the Layout of a text file in Word

M

Mike Phelps

Hi
I have a legacy system that produces reports (Print Files) that we print on
an old dot matrix printer. Someone has asked me to email them these reports
so that they can view them on screen. I can open the Print files in Word but
the layout looks nothing like the printed reports because of print control
characters etc. I've looked on the web for a utility that will convert these
file automatically but can't find one, so I though I'd try to do it using
VBA. Unfortunately even though I have written a bit of code for Excel, this
is beyond me!

Any help would be appreciated.

The text file as opened in Word looks like this:

((P))header
ABC Company Ltd. ABC Company Ltd 2737051
Date : 11/09/2003 Schedule : Z3/


Some Street, Some Town Somewhere Company : 99
Page : ((P))

XXXXXXXXX - Daily Schedule Of Deliveries
(11/09/2003) Type BB Retail/Consumer

((H))8,2
Doc
Ref No
Wine
Cases Litres
Made Wine
Cases Litres
Cider/Perry
Cases Litres
Beer
Cases Litres
Low Alcohol
Cases Litres
Totals
Cases Litres
((H))end
----------------------------------------------------------------------------
-------------------------------------------------------
((P))end

((H))8
00022382
4 36.00




4 36.00
((H))end

((H))8,6

Totals

B/Fwd

C/Fwd
------- -----------
4 36.00

0 0.00

4 36.00
------- -----------
0 0.00

0 0.00

0 0.00
------- -----------
0 0.00

0 0.00

0 0.00
------- -----------
0 0.00

50 408.00

50 408.00
------- -----------
0 0.00

0 0.00

0 0.00
------ -----------
4 36.00

50 408.00

54 444.00
((H))end
((P))trailer

It should look more like this:

ABC Company Ltd. ABC Company Ltd 2737051
Date : 11/09/2003 Schedule : Z3/


Some Street, Some Town Somewhere Company : 99
Page : 1

XXXXXXXXX - Daily Schedule Of Deliveries
(11/09/2003) Type BB Retail/Consumer


Doc Wine Made Wine Cider/Perry
Beer Low Alcohol Totals
Ref No Cases Litres Cases Litres Cases Litres
Cases Litres Cases Litres Cases Litres
----------------------------------------------------------------------------
-------------------------------------------------------
00022382 4 36.00
4 36.00

------- ----------- ------- ----------- ------- -----------
------- ----------- ------- ----------- ------- -----------
Totals 4 36.00 0 0.00 0
0.00 0 0.00 0 0.00 4
36.00
B/Fwd 0 0.00 0 0.00 0
0.00 50 408.00 0 0.00 50
408.00
C/Fwd 4 36.00 0 0.00 0 0.00
50 408.00 0 0.00 54 444.00

I can cope with finding & replacing the printing characters like
((P))trailer and newpage but its getting the data into columns that is
stumping me.

Thanks
 
J

Jonathan West

Hi Mike,

Experiment a bit with doing find & replace to modify the files manually.

Then do the same while recording a macro.

Then take a look at the code produced, and see what needs to be tweaked.

For a job like this, you'll be surprised how far you can get with just the
macro recorder. If you get stuck with a specific thing you can't manage with
the recorder, then by all means post again here.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 
M

Mike Phelps

Thanks Jonathan for the advice.

I have been using the macro recorder in Word and have managed to use find
and replace to get rid of the print markings and to insert page breaks and
numbering but it was/is really the moving of text from a (sort of ) single
column into a table that I am struggling with.

To get round this I have written a procedure that takes this file into Excel
first to change from a single column into a table and then goes back into
Word for the find and replace functions, etc. I'm sure there must be a more
elegant way of doing this all within Word but I can't get to it, but using
my Excel experience at least I can get the desired result.

Thanks again.
 

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