Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
JButkus JButkus is offline
external usenet poster
 
Posts: 1
Default Find/ replace multi-line segments?


Hey, I'm using Word 2007 on WinXP, and I was wondering if there's any
way to use the "Replace word" feature to change multi-line blocks of
text quickly and easily. And, if there's no way to do that with
Replace, is there another method I could try?

What I'm looking to do is something like this. Let's say we have this
block of text:

Pico
Pico
Pico
Fermi
Pico
Pico
Fermi
Fermi


I need to insert the word "Porkchop", as a separate line, in between
each occurence of "Pico(linebreak)Fermi", so we arrive at something
like this:

Pico
Pico
Pico
Porkchop
Fermi
Pico
Pico
Porkchop
Fermi
Fermi


Doing it by hand is right out, as I'm dealing with something like 3,000
lines here (and each file needs to be given three or four different
revisions) so any suggestions would be appreciated. Thanks!




--
JButkus
  #2   Report Post  
Posted to microsoft.public.word.newusers
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Find/ replace multi-line segments?

Replace Pico^lFermi with Pico^lPorkchop^lFermi (assuming what you have
really are line breaks; if they're paragraph breaks, use ^p instead of ^l).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

"JButkus" wrote in message
...

Hey, I'm using Word 2007 on WinXP, and I was wondering if there's any
way to use the "Replace word" feature to change multi-line blocks of
text quickly and easily. And, if there's no way to do that with
Replace, is there another method I could try?

What I'm looking to do is something like this. Let's say we have this
block of text:

Pico
Pico
Pico
Fermi
Pico
Pico
Fermi
Fermi


I need to insert the word "Porkchop", as a separate line, in between
each occurence of "Pico(linebreak)Fermi", so we arrive at something
like this:

Pico
Pico
Pico
Porkchop
Fermi
Pico
Pico
Porkchop
Fermi
Fermi


Doing it by hand is right out, as I'm dealing with something like 3,000
lines here (and each file needs to be given three or four different
revisions) so any suggestions would be appreciated. Thanks!




--
JButkus



  #3   Report Post  
Posted to microsoft.public.word.newusers
Klaus Linke Klaus Linke is offline
external usenet poster
 
Posts: 413
Default Find/ replace multi-line segments?

"Suzanne S. Barnhill" wrote:
Replace Pico^lFermi with Pico^lPorkchop^lFermi


You can also check "Match wildcards", and replace (Pico^l)(Fermi) with
\1Porkchop^l\2

\1 inserts the first (bracketed expression), \2 the second.

(assuming what you have really are line breaks; if they're paragraph
breaks, use ^p instead of ^l).


^p does not work in "Find what" with wildcards. You'd need to use
Find what: (Pico^13)(Fermi) with
Replace with: \1Porkchop^p\2

(Don't use ^13 in "Replace with"! It won't insert "real" paragraph marks)

Using wildcards may have advantages:
-- You may save some typing (especially if the texts were a bit longer than
in your example).
-- You can't make typos in the replacement text.
-- Character formatting that was applied is more likely to be preserved.

Regards,
Klaus

  #4   Report Post  
Posted to microsoft.public.word.newusers
JButkus[_2_] JButkus[_2_] is offline
external usenet poster
 
Posts: 1
Default Find/ replace multi-line segments?


OK, thanks! That's actually really useful, and it should have saved me
tons of time- I tried that technique out with a "practice file" and it
worked fine. Unfortunately, it doesn't work with the -actual- file. I
finally got a chance to sit down with it a couple minutes ago, and I
noticed a few things:

1. It's not 3,000 lines, it's actually more like 3,000 pages.
2. It's not a native Word file; it's some funky Plain Text format.

When I open it, Word asks me to convert the format so it's readable-
I've tried Windows and US-ASCII so far. The problem now is I can't for
the life of me figure out what the line breaks are! They aren't just
white space, they aren't paragraph breaks, they aren't line breaks, and
it looks like they might be line breaks followed by tabs, except that
doesn't work either... is there any way to get Word to check the
formating data for me? Or should I be using ASCII control characters
here?




--
JButkus
  #5   Report Post  
Posted to microsoft.public.word.newusers
Klaus Linke Klaus Linke is offline
external usenet poster
 
Posts: 413
Default Find/ replace multi-line segments?

First save as a Word document. As long as you haven't done so, the text file
might contain Ascii ^10 characters that are hard to deal with.
Saving in *.doc format removes that complication.

After that, you shouldn't have much trouble telling what's there if you
display the formatting characters:
See Suzanne's article http://word.mvps.org/FAQs/Formatting/NonPrintChars.htm

If that still doesn't work, you could select the characters one by one, and
run the following code in the VBA immediate window (Alt+F11, Ctrl+G):
? AscW(Selection.Text)

If you hit the Return key at the end of that line, it'll show the code of
the selected character:
9 for a tab, 11 for a manual line break, and 13 for a paragraph mark... or
possibly something else if you have a weird text file.

In "Find what" you can search for the character by code if necessary if you
preceed the code by a caret ^ or by "^u" (...so ^11 or ^u11 would find
manual line breaks just as ^l would).
The "u" in ^u stands for "Unicode"... it's optional if the code is below
256, but necessary if the code is greater than that.

Regards,
Klaus









"JButkus" wrote:

OK, thanks! That's actually really useful, and it should have saved me
tons of time- I tried that technique out with a "practice file" and it
worked fine. Unfortunately, it doesn't work with the -actual- file. I
finally got a chance to sit down with it a couple minutes ago, and I
noticed a few things:

1. It's not 3,000 lines, it's actually more like 3,000 pages.
2. It's not a native Word file; it's some funky Plain Text format.

When I open it, Word asks me to convert the format so it's readable-
I've tried Windows and US-ASCII so far. The problem now is I can't for
the life of me figure out what the line breaks are! They aren't just
white space, they aren't paragraph breaks, they aren't line breaks, and
it looks like they might be line breaks followed by tabs, except that
doesn't work either... is there any way to get Word to check the
formating data for me? Or should I be using ASCII control characters
here?




--
JButkus




  #6   Report Post  
Posted to microsoft.public.word.newusers
JButkus[_3_] JButkus[_3_] is offline
external usenet poster
 
Posts: 1
Default Find/ replace multi-line segments?


Aha, that worked like a charm. Of course, come to find out I was wrong
again... the whole 3,000 pages thing was just Word being wonky and not
giving the right data. The actual total, once all was converted to a
.doc, came to a mind-blowing 17,238 pages, give or take a couple lines.
It's been saving for about an hour now, still not finished. I'm going to
have a hell of a time tomorrow trying to get that thing reformatted, but
at least the values are changed (for the first one) and I'll be set for
the rest of this project. Thanks!




--
JButkus
  #7   Report Post  
Posted to microsoft.public.word.newusers
Klaus Linke Klaus Linke is offline
external usenet poster
 
Posts: 413
Default Find/ replace multi-line segments?

How large is that text file? Sounds as if some character (maybe ^12) is
interpreted as a "new page".

Maybe Word is the wrong tool.
Word is designed to work well with your typical text file.

If it's a huge binary file with lots of control characters -- and especially
if there aren't paragraph marks every couple of characters -- Word a hell
of a time dealing with it.

You could maybe still use VBA (from Word) to open the file and deal with the
content (either to process the contents directly, or to strip out weird
stuff so Word can then deal with it)... say using

Dim vFile as Variant
Dim myFSO
Set myFSO = CreateObject("Scripting.FileSystemObject")
Dim myTextStream
Set myTextStream = myFSO.OpenTextFile("C:\myFolder\myFile.txt",
ForReading, True)
vFile = myTextStream.ReadAll()

(add a reference to the "Microsoft Scripting Runtime" in the VBA editor,
"Tools References....", for this example)

.... and then use the VBA string functions on vPool.

I used a Variant so it's easy to use Split/Filter/Join directly.

After you've filtered/parsed/massaged the text, you can insert the result
into a new document.

Regards,
Klaus


"JButkus" wrote:

Aha, that worked like a charm. Of course, come to find out I was wrong
again... the whole 3,000 pages thing was just Word being wonky and not
giving the right data. The actual total, once all was converted to a
doc, came to a mind-blowing 17,238 pages, give or take a couple lines.
It's been saving for about an hour now, still not finished. I'm going to
have a hell of a time tomorrow trying to get that thing reformatted, but
at least the values are changed (for the first one) and I'll be set for
the rest of this project. Thanks!




--
JButkus


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Line breaks in find and replace w/ wildcards Island Girl New Users 3 May 3rd 23 02:51 PM
Find and Replace a line drawn in Word with black space. Frank[_2_] New Users 1 April 12th 07 08:07 PM
Find multiple characters in one find using MSword find/replace Cliff Microsoft Word Help 2 October 29th 06 07:48 PM
Find and Replace: delete a line & find a number 10 Janis Anna Microsoft Word Help 3 October 23rd 05 05:53 AM
Find and replace manual line breaks Orrie Microsoft Word Help 7 February 9th 05 07:40 AM


All times are GMT +1. The time now is 07:41 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"