I have a simple macro that pastes the selected text into a new document.
Selection.copy
Documents.Add
Selection.Paste
I thought of doing the same with a range. This works, but all character
formatting is lost:
Dim Target As Document, r As Range
Set r = Selection.Range
Set Target = Documents.Add
Target.Range.InsertAfter r & vbCr
Target.Activate
Is there any way to use the Range to insert the text, without losing
formatting?
arne - 07 Feb 2005 22:59 GMT
try
Sub copy_page_nothing_lost()
ActiveDocument.Bookmarks("\page").Range.Copy
Documents.Add
Selection.Paste
End Sub
Sub ccpy_section_nothing_lost()
ActiveDocument.Bookmarks("\Section").Range.Copy
Documents.Add
Selection.Paste
End Sub
arne
> I have a simple macro that pastes the selected text into a new document.
>
[quoted text clipped - 13 lines]
> Is there any way to use the Range to insert the text, without losing
> formatting?
Doug Robbins - 08 Feb 2005 00:23 GMT
From the Visual Basic Help File
This example copies the text and formatting from the selection into a new
document.
Set myRange = Selection.FormattedText
Documents.Add.Content.FormattedText = myRange

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
>I have a simple macro that pastes the selected text into a new document.
>
[quoted text clipped - 13 lines]
> Is there any way to use the Range to insert the text, without losing
> formatting?
Larry - 08 Feb 2005 00:58 GMT
Great, Doug. Thanks much.
Larry
> From the Visual Basic Help File
>
[quoted text clipped - 28 lines]
> > Is there any way to use the Range to insert the text, without losing
> > formatting?