Playing with ranges **REPOST**

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: JB (no_at_way.com)
Date: 11/03/04


Date: Wed, 03 Nov 2004 15:38:32 +0000

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



Relevant Pages

  • Re: For Each paragraph in selection when selection discontinuous
    ... funky to the selected text, then process the funky text and while processing ... For Each para In ActiveDocument.Paragraphs ... In a block of three paragraphs, select the first and last paragraph ... the two paragraphs in your selection indent. ...
    (microsoft.public.word.vba.general)
  • Re: Help With Code
    ... am I correct if I would say you use Dim ... object (like the name of a paragraph style in your document)? ... > Greg Maxey/Word MVP ... >>> which may lead beginners to stick to the selection. ...
    (microsoft.public.word.vba.general)
  • Re: Moving Styles in a script
    ... Word already has a way to apply styles to the selection. ... your add-in. ... or the selected paragraph will be formatted other than as ... clikcs on a toolbar button which initiates the macro. ...
    (microsoft.public.word.formatting.longdocs)
  • Re. Module Comments
    ... comment between Sub or Function, ... to divide a written paragraph into lines of adequate length. ... 'cursor after the last character of the selection ... 'selection of the first character in the line ...
    (microsoft.public.excel.programming)
  • Re: Word 2000 Styles not in Word2007 Styles list
    ... If I'm correctly interpreting what you're asking, I think you have to set the priority of your preferred styles to be higher than that of the others in the Quick Style gallery. ... As for updating styles, if you make a change to a single paragraph in a given style and want to update the style to include that change, you can use Update Style to Match Selection. ...
    (microsoft.public.word.docmanagement)