Inserting manual line breaks

A

ArthurN

Hi,
I'm having trouble analyzing the text from the word document with the
concordance software- to analyze the story I would first save the file as
plain text with line breaks, so that the concordance software would grab the
word and quote the story on "per line basis", not the whole sentence, which
might equal a paragraph. Besides, in this case line numbering in both
software would coincide.
Saving word doc as a plain text file does preserves line breaks,
unfortunately it
ignores those with pictures (and no picture/text wrapping works for that).
The only way out I see here is to insert a manual line break on every line
except for those that have a paragraph break.
I'm not at all strong at VBA, but may be I could write some macro that would
walk from the beginning of the file, inserting manual line breaks, ignoring
those with usual breaks (^p), until it hits the end of the file.

That's what the macro builder records when I press end and shift+enter for
the manual break
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:=Chr(11)

But I have no idea how to do the rest...
Regards,
ArthurN
 
H

Helmut Weber

Hi Arthur,

like this:

Sub Test5003x()
Dim lCnt As Long
Dim lLin As Long
ActiveDocument.Range(0, 0).Select
selection.ExtendMode = False
lLin = ActiveDocument.ComputeStatistics(wdStatisticLines)
For lCnt = 1 To lLin
selection.GoTo _
what:=wdGoToLine, _
which:=wdGoToAbsolute, _
Count:=lCnt
With selection.Bookmarks("\line").Range.Characters
If .Last <> Chr(13) And .Last <> Chr(11) Then
.Last = Chr(11)
End If
End With
Next
End Sub

Note: Switch off autohyphenation before,
otherwise the hyphens will be replaced by chr(11).

and note, too, that there are as many complications
as different ways to arrange a text.

HTH, nevertheless,

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
H

Helmut Weber

One of the complications
results from the end-of-doc mark.

So don't use:
For lCnt = 1 To lLin
Use
For lCnt = 1 To lLin - 1 instead.

Otherwise with each run of the macro,
the last character in the doc before
the end-of-doc mark will vanish.

It ain't that easy.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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