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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Emphasized or Highlighted paragraphs only in Word 2002 1

Status
Not open for further replies.

uxo22

IS-IT--Management
Feb 3, 2004
5
US
Can anyone tell me how if possible to have Word 2002 print only paragraphs highlighted with the highlight tool. For example, If I went through a document and highlighted 15 (Using words highlight tool)of 40 paragraphs and only wanted word to print the 15 highlighted prargraphs.
 
How 'bout Edit>Copy to copy the highlighted paragraphs, File>New to create a new document, Edit>Paste to paste the paragraphs to the new document, and File>Print to print 'em. I don't think there's a solution with fewer key/mouse strokes, but I've been wrong before and will be again.

(By the way, I'd have suggested CTRL-C to copy, but my Word 2002 Sp-2 seems to give me a Search and Replace window when I do that. Must investigate.)

Sloth is the mother of invention. Necessity is just a mother...
 
Sorry, maybe I didn't make ask my question clearly. I'm not trying to print highlighted items that I highlight (Select) using the mouse (like selecting text and doing a cut and paste.)For example, I select the highlight (Emphasize) tool set the color to green and highlight various paragraphs. Is there a way to make work print those paragraphs that I have highlight with the green highlight tool?

Thanks for replying. :)
 
Yes. This only works for whole paragraphs, if highlighted. It does include any whole paragraphs within table cells. It does not include sentences that are highlighted with paragraphs that are not highlighted. This parses through all the paragraphs, checking to see if the current paragraph is highlighted (with whatever color), and if it is, copies it to another document. It then prints out the document with all the highlighted paragraphs.

Sub PrintHighlights()
Dim r As Range
Dim i As Long
Dim count
Dim PrintJob As String
Dim myDoc As Document, PrintDoc As Document

Application.ScreenUpdating = False

Set myDoc = Application.ActiveDocument

Application.Documents.Add
Set PrintDoc = Application.ActiveDocument

myDoc.Activate
i = ActiveDocument.Paragraphs.count
Selection.HomeKey unit:=wdStory
For count = 1 To i
Selection.MoveDown unit:=wdParagraph, count:=1

' see if paragraph is higlighted yellow
' if using different color then change this to whatever it is
If ActiveDocument.Bookmarks("\para").Range.HighlightColorIndex = wdYellow Then
' set range for current paragraph
Set r = ActiveDocument.Range( _
Start:=ActiveDocument.Bookmarks("\para").Start, _
End:=ActiveDocument.Bookmarks("\para").End)
' select range if range is not empty
' copy to printing doc, then move back
If r.Text <> &quot;&quot; Then
PrintJob = r.Text
PrintDoc.Activate
Selection.TypeText Text:=PrintJob
Selection.TypeParagraph
myDoc.Activate
Else
End If
Else
End If
Next
PrintDoc.Activate
ActiveDocument.PrintOut
myDoc.Activate
PrintDoc.Close (wdDoNotSaveChanges)
End Sub
 
OUTSTANDING! :)

Thank you very much, I wish I was as intelligent as you folks are. Thanks again, you saved me lots of time and effort!

CT
 
Not a problem. It was an interesting exercise. I did not know how to do it myself, but it seemed like a good thing to be able to do. I have added it into my own global template of useful macros.

My first star!

Gerry
Painting/Sculpture site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top