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.

line break

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rani - 16 Sep 2006 03:44 GMT
i want to add the  text "line break start"  before the beginning of new line
and add "line break ends" after the end of the line for all the lines in MS
word doc using VBA.

can any one help me with the code of it?
Helmut Weber - 16 Sep 2006 05:32 GMT
Hi Rani,

lines or paragraphs?

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

rani - 16 Sep 2006 07:43 GMT
Hi Helmut,

i have to do it for lines. i have already done for the paragraphs.

> Hi Rani,
>
> lines or paragraphs?
Helmut Weber - 16 Sep 2006 11:17 GMT
Hi Rani,

very likely this isn't possible at all,
if there are automatic linebreaks.

If there are manual linebreaks,
then strictly speaking, it is impossible
even in theory, as the linebreak is a part of the line.
You wold have to insert your text *immediately before*
the line's end.

Which may result in a new different automatic linebreak,
and increase the number of lines of the doc.

You may play a bit with the following,
just to see, why it doesn't work.

Sub Macro3()
Dim lngL As Long
Dim lngC As Long
ActiveDocument.Range(0, 0).Select
selection.ExtendMode = False
lngL = ActiveDocument.BuiltInDocumentProperties("Number of lines")
For lngC = 1 To lngL
  selection.GoTo what:=wdGoToLine, _
  which:=wdGoToAbsolute, _
  Count:=lngC
  selection.Bookmarks("\line").Range.InsertBefore "yyyy"
  selection.Bookmarks("\line").Range.InsertAfter = "xxxx"
Next
End Sub

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

rani - 17 Sep 2006 00:58 GMT
Thanks Helmut your information and code was very hepful. i really appreciate
that.

> Hi Rani,
>
[quoted text clipped - 27 lines]
> Next
> End Sub
Doug Robbins - Word MVP - 16 Sep 2006 12:18 GMT
That is going to really screw up the present line breaks.  When you add the
"line break start" at the beginning of the line, some of the text that was
towards the end of the line will wordwrap onto the next line.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi Helmut,
>
[quoted text clipped - 3 lines]
>>
>> lines or paragraphs?
rani - 17 Sep 2006 01:00 GMT
Thanks Doug. that was quite helpful

> That is going to really screw up the present line breaks.  When you add the
> "line break start" at the beginning of the line, some of the text that was
[quoted text clipped - 7 lines]
> >>
> >> lines or paragraphs?
 
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.