Results 1 to 2 of 2

Thread: Text wrapping break in word

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    9

    Text wrapping break in word

    Hello,

    I am importing word document to another application. The documents imports fine except that sometimes the word wrapping is different. To overcome this, I inserted text wrapping breaks (Inseart--> Break--> Text wrapping break) at the end of each line of the word document. The documents are usually only paragraphs with text lines.

    Now, repeating the above step manually is bound for errors...sometimes somelines get missed out for inserting the breaks. I want to do the following using VBA :

    1) Scan through the word document and list the lines or line numbers that doesnot have this text wrapping breaks at the end of the line.

    2) If there are lines found in step 1 above, insert the text wrapping breaks using the same VBA.

    Any help or sample code will greatly help me.
    Thanks!

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    Give this a whirl:

    VB Code:
    1. Dim rngLine As Range
    2.  
    3. Set rngLine = ActiveDocument.Range(ActiveDocument.Range.Start, ActiveDocument.Range.Start)
    4. For i = 1 To ActiveDocument.ComputeStatistics(wdStatisticLines)
    5.     Set rngLine = rngLine.GoTo(What:=wdGoToLine, Which:=wdGoToNext, Count:=1)
    6.     intLastChar = Asc(ActiveDocument.Range(rngLine.Start - 1, rngLine.Start).Text)
    7.     If intLastChar <> 11 And intLastChar <> 13 Then
    8.         rngLine.InsertBreak Type:=wdTextWrappingBreak
    9.     End If
    10. Next i

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width