macro to extract multiple text selections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to be able to extract a whole lot of highlighted words and phrases
from a long Word document and copy them as a list to a new document.

One solution seems to be to use Spike, and I've recorded the following macro
(which I've called "multispike") to copy each highlighted word/phrase to
Spike. Where I need help, please, is with getting this macro to loop so that
it will run through the whole document.

Sub multispike()
'
' multispike Macro
' Macro recorded 23/04/2007 by dn
'
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
NormalTemplate.AutoTextEntries.AppendToSpike Range:=Selection.Range
End Sub

And I'm also unsure how many selections Spike can handle. Is it feasible to
even attempt this method with a really long document (more than 200 pages,
with several hundred highlighted bits of text that I'm trying to extract)?
The document (a book manuscript) consists of about a dozen chapters and I can
always repeat the operation one chapter at a time, but it would be more
convenient to do the whole job at once.

And maybe there's a better way to approach the whole task. Any suggestions
will be most gratefully received.
 
What version of Word are you using? As of Word 2002 you can use
noncontiguous text selection. Then all you need to do in Find is use "Find
All" and then copy/paste the found results as desired.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Co-author of Word 2007 Inside Out:
http://www.microsoft.com/MSPress/books/9801.aspx#AboutTheBook

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
Many thanks Beth. That does exactly what I wanted. Now my only problem is
trying to figure out what I did wrong when I tried that out to begin with!
 
Glad to hear the solution will work for you. :-)

For some reason, sometimes what it takes is confirmation that what you
thought should work actually does work. ;-)

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Co-author of Word 2007 Inside Out:
http://www.microsoft.com/MSPress/books/9801.aspx#AboutTheBook

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
Back
Top