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 / September 2006

Tip: Looking for answers? Try searching our database.

Inserting manual line breaks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ArthurN - 25 Sep 2006 01:12 GMT
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
Helmut Weber - 25 Sep 2006 17:06 GMT
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,

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Helmut Weber - 25 Sep 2006 17:30 GMT
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.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

ArthurN - 26 Sep 2006 01:08 GMT
Thank you, Helmut Weber,
It's just what I needed
 
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.