Finding several paragraphs of text

P

Petra Liverani

I would like to find several paragraphs of text beginning
and ending with certain strings where the number of
paragraphs will not always be the same. I tried doing a
Search using Wildcards but the best I could come up with
was finding text when the number of paragraphs was set,
eg, putting in the Search Box for 3 paras
blahblah^013*^013*^013*blahblah. I don't know if this
Search code can be refined so that there can be any number
of paras or whether you have to do something completely
different with VBA.

Thanks for any help.
 
K

Klaus Linke

Hi Petra,

Find what: start*end
would match any text that starts with "start" and ends with "end", no
matter how many paragraphs that text spans.

Find what: start*^13*end
would only match if at least one paragraph mark is between "start" and
"end".

Find what: start[!^13]@^13[!^13]@end
would match only if exactly one paragraph mark is between "start" and
"end".

Hope that this helps you somewhat.
If not, post back!

Klaus
 
P

Petra Liverani

Hi Klaus,

I thought I'd tried the start*^13*end option and it didn't
work - perhaps I forgot to check the Wildcard box or I
didn't enter my strings correctly.

Yes, it works perfectly. Since I posted my message I
thought of another way - finding the first string of text
then using extend selection and finding the second string
but obviously the Wildcard method is easier.

Thanks for your reply.

Regards,
Petra
-----Original Message-----
Hi Petra,

Find what: start*end
would match any text that starts with "start" and ends with "end", no
matter how many paragraphs that text spans.

Find what: start*^13*end
would only match if at least one paragraph mark is between "start" and
"end".

Find what: start[!^13]@^13[!^13]@end
would match only if exactly one paragraph mark is between "start" and
"end".

Hope that this helps you somewhat.
If not, post back!

Klaus



Petra Liverani said:
I would like to find several paragraphs of text beginning
and ending with certain strings where the number of
paragraphs will not always be the same. I tried doing a
Search using Wildcards but the best I could come up with
was finding text when the number of paragraphs was set,
eg, putting in the Search Box for 3 paras
blahblah^013*^013*^013*blahblah. I don't know if this
Search code can be refined so that there can be any number
of paras or whether you have to do something completely
different with VBA.

Thanks for any help.

.
 
K

Klaus Linke

Yes, it works perfectly. Since I posted my message I
thought of another way - finding the first string of text
then using extend selection and finding the second string
but obviously the Wildcard method is easier.


If you need it for a macro that you are going to use a lot, I'd do some
experiments to check which method is faster.

Wildcard searches can be slow if the "*" joker is involved, especially more
than once, because Word has to keep track of lots of possible matches.
Extending the selection might actually be faster.

Klaus
 

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