View Single Post
  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Jezebel
 
Posts: n/a
Default Finding lines containing one word

Here's some code that you might be able to adapt --

Dim pPar As Word.Paragraph
Dim pRange As Word.Range

For Each pPar In ActiveDocument.Paragraphs
Set pRange = ActiveDocument.Range(pPar.Range.End - 1,
pPar.Range.End)
If pRange.Information(wdHorizontalPositionRelativeToP age) x Then
...
End If
Next

This checks the horizontal position of the end-of-paragraph, and does
something if the last line of the paragraph is less than some value. Not
quite what you're asking, but maybe sufficient. You'll need to insert a
value for x (in points) that's your threshhold of interest (ie, do something
if the last line is shorter than this value). And you'll need to insert
whatever you actually want to have happen, eg select the line and stop, or
format the last word in some way that you can then use with Find.



"jezzica85" wrote in message
...
All I'm trying to do is go through a document just to see how many times
that
happens, it's more of a weird trivia-ish thing, not really for any real
purpose except so I know in case I want to print the document later.

"Jezebel" wrote:

That's a much harder task. I can think of several ways to do it, but only
with a fair amount of tricky macro programming. What are you actually
trying
to achieve?



"jezzica85" wrote in message
...
Thank you Jezebel, but it looks like I wasn't clear enough with my
question.
What I'm looking for is:

if I had a sentence like
this

"or a sentence like this that just overflowed naturally with dialogue
like
this--"

Would there be a way to just scan a document for the "this's,"
basically
just a single word in a line, but not necessarily the start of a
paragraph?
Thanks!

"Jezebel" wrote:

Assuming 'line' means paragraph and 'only one word' means that the
paragraph
contains no spaces: with 'Use wildcards' checked --

Find: ^013[! ]@^013
Replace: ^pxxx^p

where xxx is your replacement text. Note that this won't do the very
first
paragraph of the document.



"jezzica85" wrote in message
...
Hi all,
Does anyone know if there's a way to use Find and Replace to find
all
the
lines in a document that only have one word on them?
Thanks!
Jezzica85