Getting to the end of range

S

Sukhi

Hello
I use Range object to insert text in paragraphs. when text is inserted, the
cursor still stays at the beginning (at the book mark).

Set rBMRange = .Bookmarks("P1_WhatYouMightGetBack").Range
rBMRange.Text = Trim(rsMYS!para_text)
I want to carry on typing more text from database, without having
unnecessary bookmarks.

How do I get to end of text, and how do I type carriage return
(selection.typeparagraph with selection).
 
D

Dave Lett

Hi,

You can use something like the following:

Set rBMRange = ActiveDocument.Bookmarks("P1_WhatYouMightGetBack").Range
''' insert your text and add a paragraph at end of range
rBMRange.Text = Trim(rsMYS!para_text) & vbCrLf

'''select the end of the range
rBMRange.Collapse Direction:=wdCollapseEnd
rBMRange.Select

HTH,
Dave
 
S

Sukhi

Thanks Dave
That works wonders, I get the new paragraph from database and just display
it :--
rBMRange.text="This is the new paragraph displayed after the carriage
return"

Now, what if some of the text in above paragraph is in Bold, as I understand
I can only do this
rBMRange.bold=true, which apply to whole text.

I can store the bold text in different row in database, but that is too messy.

Is there a way to format part of the text in range

Sukhi
 
D

Dave Lett

Hi,

Yes, you can format all or part of the range.
rBMRange.Words(4).Bold = True
will make "new" bold whereas

rBMRange.Find.Execute FindText:="paragraph"
rBMRange.Bold = True
will make "paragraph" bold

HTH,
Dave
 
S

Sukhi

Thanks dave
but I need find text in range within '' marks and make it bold then move on
to next single quotes and so on.

for example
You must read the later sections starting ‘What you might get back when
you are <Retirement_Age>' to see the important notes.

in the above example i need from 'What you......<Retirement_Age>' bold, i
cant use find, cos <Retirement_Age> is populated at run time.

Thanks in advance
 

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