Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

read the whole section

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
john smith - 06 Sep 2006 22:20 GMT
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!
Jezebel - 06 Sep 2006 22:34 GMT
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.

> EXAMPLE:
> 1         Scope of Test
[quoted text clipped - 23 lines]
>
> Thankyou so much for your help before!
john smith - 07 Sep 2006 00:48 GMT
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.

> 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
[quoted text clipped - 27 lines]
>>
>> Thankyou so much for your help before!
Jezebel - 07 Sep 2006 01:35 GMT
Dim pSection as string

pSection = ActiveDocument.Sections(1).Range

> Read means that only read the section "1.scope of test" content and save
> it into a variable.
[quoted text clipped - 33 lines]
>>>
>>> Thankyou so much for your help before!
Wraithchilde - 09 Nov 2006 15:30 GMT
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.
Jean-Guy Marcil - 07 Sep 2006 12:51 GMT
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
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

john smith - 07 Sep 2006 21:30 GMT
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

> john smith was telling us:
> john smith nous racontait que :
[quoted text clipped - 56 lines]
> End Sub
> '_______________________________________
Jean-Guy Marcil - 08 Sep 2006 02:31 GMT
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.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Jezebel - 08 Sep 2006 02:45 GMT
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.

> Hi Jean,
>
[quoted text clipped - 64 lines]
>> End Sub
>> '_______________________________________
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.