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 / November 2004

Tip: Looking for answers? Try searching our database.

Playing with ranges **REPOST**

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JB - 03 Nov 2004 16:38 GMT
Old Post-----------

Hi Guys,
Sorry I wasn't clearer.

I'm selecting the text in the paragraph manually....say the paragraph
looked like this -

"My Paragraph has SELECTED TEXT and this is what I want to be a link
entering a new word HERE".

I've tried insertafter but it goes after the paragraph and onto the new
line when I use with myRng.MoveEnd...didn't try wdcollapseEnd though.

    Dim myrng As Range

        Set myrng = Selection.Range
        myrng = myrng.Paragraphs(1).Range

        myrng.MoveEnd
        myrng.InsertAfter " MyText"

Cheers

J

---------------------

Forgot to mention that after the text is selected in the para the user
clicks a custom macro button, the macro Changes the selection to make
the selected text the anchor and inserts text before the anchor which is
the Href to the linked document.

So I can't select the whole para at the start as I'll lose my selection
and I can't select the whole para at the end as I'll lose my formatting
for the anchor.

Cheers

J
Dave Lett - 03 Nov 2004 17:38 GMT
Hi JB,

I think you're looking for something like the following:

Dim oRng As Range
Set oRng = ActiveDocument.Range _
   (Start:=Selection.Paragraphs(1).Range.End - 1, _
   End:=Selection.Paragraphs(1).Range.End - 1)

oRng.InsertAfter Text:="New Text"

HTH,
Dave

> Old Post-----------
>
[quoted text clipped - 36 lines]
>
> J
JB - 04 Nov 2004 12:58 GMT
> Hi JB,
>
[quoted text clipped - 50 lines]
>>
>>J

So simple when you know how.....  :-)

Thanks Dave.

J
 
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.