Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assemble highlighted word scraps into a separate doc easily

Status
Not open for further replies.

raygg

Technical User
Jun 14, 2000
397
0
0
US
Am trying to make the transition from studying and making notes in a real book to using electronic pdf and word docs as the source. In working with long electronic docs it would be helpful to automate the note taking process for doing further analysis.

What I would like to do with a word document is to highlight various sentences and parts of paragraphs as I go through the doc - and at some point collect all those highlighted sections - be they 10 words long or 3 paragrahs - or whatever length - and sequentially make them "jump" into a new document in a numbered sequence just like I found them. It would be great if this process can be arranged so the sections I highlighted stay highlighted from one session with the pc to another sesiion.

In other words, pre-PC - people would study a book and make notes into a hardcopy spiral or 3ring notepad/book - but in this electronic document world we live in I want to analogize that process by highlighting in a word doc and then make those highlighted scraps form a new "notebook" in another document.

I have used the MS Word document comment facility but am not sure if this is somehow adaptable to what I want to do.

Is there a process in MS Word to do what I seek to do or is it just too cludgy to attempt?
 
IF you are talking about actual highlighting, and
IF that highlight is yellow

Code:
Sub FindHighlights()
Dim r As Range
Dim ExtractedDoc As Document
Dim SourceDoc As Document

Set SourceDoc = ActiveDocument
Set ExtractedDoc = Documents.Add
Set r = SourceDoc.Range

With r.Find
   .Text = ""
   .Highlight = wdYellow
   Do While .Execute() = True
      ExtractedDoc.Range.InsertAfter r.Text & vbCrLfText
   Loop
End With
End Sub

Creates a new document, and extracts each found highlighted chunk - be it part of a sentence, part of a paragraph, or multiple paragraphs - and puts them in that new document.

Gerry
 

When the document is saved the highlighted chunks are saved as well.

Gerry
 
>I have used the MS Word document comment facility but am not sure if this is somehow adaptable to what I want to do

Absolutely

ActiveDocument.Comments is a collection that holds all the comments for a document. You can extract the text the comment refers to simply with:

ActiveDocument.comments(n).Scope.Text

So you might have some pretty lean code as follows:

Code:
[blue]Public Function ExtractNotes(SourceDoc As Document) As Document
    Dim myNote As Comment
    
    Set ExtractNotes = Documents.Add    
    For Each myNote In SourceDoc.Comments
        ExtractNotes.Range.InsertAfter myNote.Scope.Text & vbCrLf
    Next
End Function[/blue]

It also has the advantage that a Comment has a bunch of additional info that you might want in the new document: eg the name and/or initials of the person that inserted the comment, the date the comment was made, and the text of the comment itself if any.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top