read per word until the end page(page break)

J

john smith

Hi,

I tried to read per word from my table of content below and write per
paragraph
into the text file.
It's not working since it only read the first 3 lines and after that I
always get 'bad parameter' message error due to tab error in the table of
content like:
1.3 Test
1.3.1 Error read this line.
Would anyone know how to read per word and write value per line in text file
until the
page break(end of page)?
Please help me...!

Thank you so much...
John

Part II Test Cases 8

1 Central Management Console (CMC) 8

1.1 CMC Sanity Check 8

1.2 Folders 10

1.3 Crystal Report 18

1.3.1 Add Report 19

1.3.2 Preview Report 23

1.4 Program and 3rd Party Objects 29

1.4.1 Add Objects 29

1.4.2 Program Object Viewing. 31

1.5 Categories 33

1.5.1 Create Category. 34

1.5.2 Modify Category. 35

1.5.3 Delete Category. 37

1.5.4 Assign Category. 38

1.5.5 Move Category. 39

1.5.6 Apply Rights to Category. 41

1.6 Universe (Sanity) 42
--------------------------page break-----------------------

Sub readtableofcontent()
Dim oRngH As Word.Range
Dim NextLine As Integer
Set oRngH = ActiveDocument.Range
NextLine = 2

With oRngH.Find
.Text = "Part II Table of Content"
.Font.Name = "Verdana"
.Font.Size = 10
If .Execute Then
oRngH.Move wdParagraph, NextLine
While
(oRngH.Application.ActiveDocument.Paragraphs.Last.Range.Text <> Chr(11))
oRngH.Move NextLine
NextLine = NextLine + 1
oRngH.Expand wdParagraph
objFile.writeLine (oRngH.Text)
Wend
End If
End With
end sub
 
J

john smith

i tried to find but can find it. Would you please repeat it again Jezebel?
Since it's very important for me to work on this.

Thank you so much Jezebel!
John
 
J

Jean-Guy Marcil

john smith was telling us:
john smith nous racontait que :
i tried to find but can find it. Would you please repeat it again
Jezebel? Since it's very important for me to work on this.

Perfect example of why it is not a good idea to multi-post the same question
to many groups.
I saw it in word.vba.general, but I don't remember where exactly.

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

Russ

John,
Is this the message thread with Jezebel's answer that you were looking for?
Click on link:
http://tinyurl.com/gshmw
Jezebel's code writes the TOC directly to a new file on the hard drive,
which you later open and use as you wish. You must give your own legitimate
path and filename in the code in order for it to work correctly. Search for
"open" in VBA help to read the various links about writing-to-files
directly.
 

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