Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2002
    Posts
    134
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Word 2010 - Print only pages with certain phrase on them

    Is there anyway you run a search for a certain phrase and then print only the pages where that phrase shows up? We have a 500+ document and maybe 100+ hits for the phrase we are looking for. We would like to be able to print only those pages without printing them a page at a time. Is there any way in Word 2010 to do that?

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Caniac,

    Here's some VBA that will turn the trick.
    Code:
    Option Explicit
    
    Sub MyFindAndPrint()
      
      Dim myRange As Range
      Dim bResult As Boolean
      
      Selection.WholeStory   'Select entire document
    
      With Selection.Find
    '**** Syntax of Find Execute incase you want to use some of the
    '**** other parameters.
    '         expression .Execute(FindText, MatchCase, MatchWholeWord, _
    '          MatchWildcards, MatchSoundsLike, MatchAllWordForms, _
    '          Forward, Wrap, Format, ReplaceWith, Replace, MatchKashida,_
    '          MatchDiacritics, MatchAlefHamza, MatchControl)
              
        .ClearFormatting
        .MatchWholeWord = True
        .MatchCase = False
        
        Do
          bResult = .Execute(FindText:="passwords")  '<- Your phrase here!
          If bResult Then
      '      Debug.Print bResult
            Application.PrintOut FileName:="", Range:=wdPrintCurrentPage, Item:= _
              wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
              wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
              PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
              PrintZoomPaperHeight:=0
          End If
        Loop Until Not bResult
      End With
       
    End Sub     'MyFindAndPrint
    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •