Hi Andrea,
Use:
Dim doc1 As Document
Dim doc2 As Document
Dim drange As Range, drange2 As Range
Set doc1 = ActiveDocument
Set doc2 = Documents.Add
doc1.Activate
With Selection
.HomeKey wdStory
.Find.Highlight = True
While .Find.Execute
Set drange = doc2.Range
drange.Collapse wdCollapseEnd
drange.FormattedText = .Range.FormattedText
drange.InsertBefore "Page: " &
..Information(wdActiveEndAdjustedPageNumber) & _
" / Line: " & .Information(wdFirstCharacterLineNumber) & _
" / Text: "
drange.InsertAfter " / Font Name: " & .Range.Font.Name & vbCr
Set drange2 = drange.Duplicate
drange2.End = drange2.Start + InStr(drange2, " / Text: ") + 8
drange2.Font.Reset
drange2.HighlightColorIndex = wdAuto
Set drange2 = drange.Duplicate
drange2.Start = drange2.Start + InStrRev(drange, "/") - 2
drange2.Font.Reset
drange2.HighlightColorIndex = wdAuto
Wend
End With
doc2.Activate
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
In your code, use
" / Text: " & .range.FormattedText &
in place of
" / Text: " & .range.Text &
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Hey Tony,
thank you very much for your quick help. You may have gotten my
question wrong. I would like the highlighted text to be copied into
the target document as formatted text. That is, this highlighted text
may be underlined or italic or have some specific font. I hope you get
what I mean with englisch being not my mother tongue.
Regards, Andreas- Hide quoted text -
- Show quoted text -
Hi Dough,
thank you for your swift reply. I am afraid to say that no formatted
text is copied into the target document with this adjustment of the
code.
Regards, Andreas