Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Getting Word Paragraph Number

Reply
 
Old 02-05-2009   #1 (permalink)
Codeblack


 
 

Getting Word Paragraph Number

Hi All,

I have a written a vbscript which will search for some text in a word
document and if a match is found then, that paragraph will be written to
another word file or text file. I was able to acheive this but the problem is
I dont know how to get the paragraph number where the match is found.

Can anyone tell me how to get the current paragraph number.

Thanks in advance.

My System SpecsSystem Spec
Old 02-05-2009   #2 (permalink)
mr_unreliable


 
 

Re: Getting Word Paragraph Number

Codeblack wrote:
Quote:

> I have a written a vbscript which will search for some text in a word
> document and if a match is found then, that paragraph will be written to
> another word file or text file. I was able to acheive this but the problem is
> I dont know how to get the paragraph number where the match is found.
>
hi CodeBlack,

I have never done this, but here is a suggestion
(call it a "brute force" approach).

Try using the "Paragraphs Object". That is a property
of your (word) document. It will return a "collection"
of paragraphs in the document.

Then "restructure" your search. Use the For...Next
approach to go through the document paragraph-by-paragraph,
and select each paragraph. Then search for your key phrase
WITHIN THE SELECTION (i.e., just the current paragraph, not
in the entire document). When you find a hit, then you know
the paragraph number -- it would be the index of the
paragraph you are working on.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Line spacing (paragraph separation) fails sometimes Live Mail
New line in stead of new paragraph VB Script
When I type the words skip to previous paragraph Vista General
Number of copies using Word 2007 Vista print fax & scan


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46