Word Macro help needed

D

Dave

Hi folks!

I need some help with a word macro. I've never really written one
before and my attempts have been pretty feeble.

I have a report that originally came from a mainframe, which contains
the single digit '1' in the first column to signify a page break.

I want a macro that looks for a '1' at the start of a line, and
replaces it with a ^m every time.

It should be simple, I guess, but I've failed miserably so far.

Can anyone help?

Dave
 
M

Michael Bednarek

On 13 Feb 2006 06:31:09 -0800, "Dave" wrote in microsoft.public.word:

[snip]
I have a report that originally came from a mainframe, which contains
the single digit '1' in the first column to signify a page break.

I want a macro that looks for a '1' at the start of a line, and
replaces it with a ^m every time.
[snip]

Ahh ... the old Skip to Channel 1 control - printers with hole control
tapes - IBM 1403 ...

You could just run a Find/Replace operation:
Find: ^p1^p
Replace: ^p^|
will replace lines whith only "1" in them with a Manual Linebreak (I
assume that's what you mean by ^m; natively, Ctrl+M will indent a
paragraph from the left in MS Word).

This will not work for the very first line if it contains such a "1".

As a macro, this could do the same:
With ActiveDocument.Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^p1^p"
.Replacement.Text = "^p^l"
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With

Good luck.
 

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