Copy Paste Special Challenge

M

Mr M Walker

Is it possible to copy a word document page but leave the first 3 space
behind on every line for the whole document I need to do this for over 3000
pages so do not want to by line by line I am trying to achieve:

001 dsfdsfsd
002 sdfdsfsdf
003 sdfdsfsdf

to becomes

dsfdsfsd
sdfdsfsdf
sdfdsfsdf

is this possible

Many thanks

Marcus

Marcus
 
C

Chuck Henrich

How's this - it goes through each paragraph (assuming each line is actually a
paragraph) and strips off the first 4 chars):

Dim x As Long
Dim strString As String

With ActiveDocument
For x = 1 To .Paragraphs.Count
strString = .Paragraphs(x).Range.Text
strString = Right(strString, Len(strString) - 4)
.Paragraphs(x).Range.Text = strString
Next x
End With

HTH
 
C

Chuck Henrich

An alternative method not using a macro would be to use a wildcard search:

Search for: ([0-9]{3}) (*)
Replace with: \2

(Note that there is a space after {3} and before the closing round bracket.
{3} specifies how may digits - if there were 5 digits you'd change the 3 to a
5. Make sure "Use wildcards" is ticked.)

By putting round brackets around any text you can "mark" it as a discrete
component that can be referred to in the replace with field as "\1" (first
bracketed section), "\2" (second bracketed section) etc.

For more information look at the (murky) help section on wildcard searches.

HTH
 

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