Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 09-12-2012, 06:36 AM
jperez84 jperez84 is offline Find, copy and paste into a new page Windows XP Find, copy and paste into a new page Office 2007
Novice
Find, copy and paste into a new page
 
Join Date: Sep 2012
Posts: 21
jperez84 is on a distinguished road
Default

Sorry about the cross posting. I didn't think about someone doing double work or trying to solve a problem when someone on another forum already had.

I've been working on my above dilema and have a working macro(found it online and have been able to modify it a bit to my needs). I'm just trying to modify it a bit. Instead of searching 1 word or phrase at a time is there a way to have a list and it can pull from the next word or phrase with each loop until it hits the end? Also is the a way to number each hit and put it all into 1 doc. Below is the code that I have so far.

Code:
 
Sub Demo()
Dim SearchTerm As String, i As Long
Dim Rng As Range, Doc As Document, RngOut As Range
 
SearchTerm = InputBox("Enter your search terms")
SearchTerm = LCase(Trim(SearchTerm))
If Len(SearchTerm) = 0 Then Exit Sub
 
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = SearchTerm
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = False
    .Execute
  End With
  If .Find.Found Then
    Set Doc = Documents.Add(Visible:=False)
    Do While .Find.Found
      Set Rng = .Duplicate
      With Rng
        .MoveStartUntil Cset:="^^^^^", Count:=wdBackward
        .MoveEndUntil Cset:="^^^^^", Count:=wdForward
        .Select
        If MsgBox(.Text, vbYesNo, "Copy this block?") = vbYes Then
          .Copy
          With Doc
            .Range.InsertAfter "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
            Set RngOut = .Characters.Last
            RngOut.Paste
          End With
        End If
      End With
      .Collapse wdCollapseEnd
      .Find.Execute
    Loop
    Doc.Activate
    ActiveWindow.Visible = True
  End If
End With
End Sub
Thanks,
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find, copy and paste into a new page copy and paste not working Ellie Word 3 11-07-2013 02:23 PM
Can't copy paste irenasobolewska Office 2 10-26-2012 05:09 PM
Find, copy and paste into a new page special copy/paste iconofsin Excel 1 09-15-2010 12:10 AM
Copy - Paste between 2 tables rod147 Excel 1 10-22-2009 08:21 PM
Copy & paste low resolution worriedme Drawing and Graphics 0 06-01-2009 03:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft