Re: Copying paragraphs including formatting.

From: Malik Al-Amin (malamin_at_ddd.com)
Date: 12/15/04


Date: Wed, 15 Dec 2004 17:03:45 -0600

Thanks Jezebel

Is it more appropriate to use one over the other? Basically what I'm doing
is I have document1 open and I run a macro that opens up a document2. This
macro copies certain paragraphs from document one and certain paragraphs
from document two and merges them together in document3. I was using the
range object as I was under the impression that this was the object to use
if you're not highlighting anything in the document interface. is my logic
wrong? When merging things back together I want to keep the original
formatting of the paragraphs from their original sources. It was explained
how to do this via the selection object. Is that the way I should be heading
with this?

"Jezebel" <dwarves@heaven.com.kr> wrote in message
news:exOmugv4EHA.1404@TK2MSFTNGP11.phx.gbl...
> The Selection object is just a special case of Range object. For most
> coding
> purposes Selection and Ranges are interchangable.
>
>
>
>
> "Malik Al-Amin" <malamin@ddd.com> wrote in message
> news:%23KPJzSv4EHA.1400@TK2MSFTNGP11.phx.gbl...
>> Is there a way to achieve the same thing using the "range" object. I
>> chose
>> to use the range object instead of the selection object in my solution.
>> Since I'm using the range object i don't have anything "selected". How do
> I
>> get around this limitation?
>>
>> Thanks
>> "Jean-Guy Marcil" <no-spam@leaveme.alone> wrote in message
>> news:eYQoXhu4EHA.2568@TK2MSFTNGP11.phx.gbl...
>> > Malik Al-Amin was telling us:
>> > Malik Al-Amin nous racontait que :
>> >
>> >> Hi all,
>> >>
>> >> I know how to copy over the contents of a paragraph to a new document.
>> >> However my text is copied over but looses all of the formatting. How
>> >> can I copy and at the same time keep the formatting, including any
>> >> blank lines between sentences? Any ideas?
>> >>
>> >
>> > See the FormattedText property.
>> >
>> > Try this silly example on formatted text to see how it works:
>> >
>> > '_______________________________________
>> > Dim MyRange As Range
>> >
>> > Set MyRange = Selection.Range.FormattedText
>> >
>> > Selection.Collapse wdCollapseEnd
>> > Selection.TypeParagraph
>> > Selection.FormattedText = MyRange
>> > '_______________________________________
>> >
>> > --
>> > Salut!
>> > _______________________________________
>> > Jean-Guy Marcil - Word MVP
>> > jmarcilREMOVE@CAPSsympatico.caTHISTOO
>> > Word MVP site: http://www.word.mvps.org
>> >
>> >
>> >
>>
>>
>
>



Relevant Pages

  • Re: Clearing the Undo memory cache in Word to avoid sluggish beh
    ... The biggest single thing you can do to speed up the macro is this: ... When you move or manipulate the Selection object, ... With a Range object, the screen is unaffected. ... I do not need the 'Undo' feature of Word ...
    (microsoft.public.word.vba.general)
  • Re: Opening Word
    ... use the range object instead of the selection object, ... macro is doing its thing in a non-visible instance of word. ...
    (microsoft.public.word.vba.general)
  • Re: Word macro - maintaining scroll position
    ... Another way is to modify your macro so you don't have to move the selection. ... Pretty much anything you do with the Selection object you can do with the Range object. ... Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.docmanagement)
  • Re: MoveRight in table fails at 1%: bug? workaround?
    ... temporary files as your macro runs, so that all changes can be undone. ... about erros at Selection.MoveRight command? ... >> Does anyone know something like a known bug about MoveRight? ... Using the Selection object makes for more convoluted ...
    (microsoft.public.word.vba.general)
  • Re: Word performance problems
    ... another Range object to find the defining term. ... strings, and at the end of the macro, it pulls the information from ... view and turns background repagination off, ... when the macro encounters an acronym. ...
    (microsoft.public.word.vba.general)