read the whole section

J

john smith

EXAMPLE:
1 Scope of Test
This test case specification covers the test criteria necessary to ensure
that the Central Management Console functionality is working correctly.

In particular; the test cases are focused on object testing the following
tasks; though; testing of Server Management and User Management features
are not in the scope of this document.

OLAP related testing is not covered in this document

2 Assumptions and Constraints
The tester has familiarity with most of the functionality of Business
Objects Enterprise.









Hi,



I'd like to read whole section content. Like for example above, I'd like to
read the section content of "1 Scope of Test" which contain "This test case
specification cover.... until

OLAP related testing is not covered in this document" Afterwards, just save
it in a variable.





Is there anyone know how to do it?



Thankyou so much for your help before!
 
J

Jezebel

You must be using 'read' in a special sense: it might help if you explained
it. Perhaps you could find someone who speaks English to help re-phrase your
question.
 
J

john smith

Read means that only read the section "1.scope of test" content and save it
into a variable.
Just that '1.Scope of Test' section content, no other section will be read
afterwards.
 
J

Jean-Guy Marcil

john smith was telling us:
john smith nous racontait que :
Read means that only read the section "1.scope of test" content and
save it into a variable.
Just that '1.Scope of Test' section content, no other section will be
read afterwards.

The easiest way to make this work is to use styles to define the key
paragraphs which are
"1 Scope of Test"
and
"2 Assumptions and Constraints"
in your example.

In my example I assume that they are attributed the Style Heading 1. In the
code, replace "wdStyleHeading1" with whatever style you are using.
Also, I included two tests:
The cursor must be placed in a paragraph with that style (or the macro would
not know where to start) and I check for the end of the document to avoid
error messages or endless loops.

'_______________________________________
Sub SelectText()

Dim parCurrent As Paragraph
Dim rgeFinal As Range
Dim lngParCount As Long
Dim lngParIndex As Long

lngParCount = ActiveDocument.Paragraphs.Count
Set parCurrent = Selection.Paragraphs(1)
lngParIndex = ActiveDocument.Range(0, parCurrent.Range.End) _
.Paragraphs.Count

If parCurrent.Range.Style <> ActiveDocument _
.Styles(wdStyleHeading1) Then
MsgBox "You must place the cursor in a pargraph formatted " _
& "with the style ""Heading 1"".", vbExclamation, _
"Wrong style"
Exit Sub
Else
Set rgeFinal = parCurrent.Range
Do While lngParIndex < lngParCount
Set parCurrent = rgeFinal _
.Paragraphs(rgeFinal.Paragraphs.Count).Next
lngParIndex = lngParIndex + 1
If parCurrent.Range.Style <> ActiveDocument _
.Styles(wdStyleHeading1) Then
rgeFinal.End = parCurrent.Range.End
Else
Exit Do
End If
Loop
End If

MsgBox rgeFinal.Text

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

john smith

Hi Jean,

Can we do this automatically by finding that particular title name like "6.
Validation Method" and read the below content of it, store it into
variable. Until it finds "7. Platform Applicable" and stop reading?

Thanks
 
J

Jean-Guy Marcil

john smith was telling us:
john smith nous racontait que :
Hi Jean,

Can we do this automatically by finding that particular title name
like "6. Validation Method" and read the below content of it, store
it into variable. Until it finds "7. Platform Applicable" and stop
reading?

Just before the line:
Set parCurrent = Selection.Paragraphs(1)
you could have code that would ask the user what bit of text they want to
use as a starting point. See the on-line help for "InputBox ".

But asking users to type is more likely to create errors. It is much easier
just to ask the user to place the cursor in the paragraph they want to start
from...
Otherwise, what I would do is have a userform with a combobox that would
list all the Level 1 paragraphs. The user would then select the one they
want to use. This way, no typing errors!

Or, if the paragraph to start from is always the same, you could hard code
its text in a constant and do Search in the code just before that line. See
the Find method in the on-line help.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jezebel

Put a section break immediately before each of your headings, then you can
use

a) ActiveDocument.Sections(n).Range to retrieve the entire content of each
section into a variable, and

b) ActiveDocument.Sections(n).Paragraphs(1).Range to retrieve the heading
for each section.
 
W

Wraithchilde

Jezebel you are awesome. I was trying to figure out how to save a document
with about 500 sections as individual documents and I came across this
answer. Perfect.
 

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