April 9, 2024
Contribute to the Microsoft 365 and Office forum!
Click here to learn more 💡
May 10, 2024
Word Forum Top Contributors:
How to export the results of a word search using word 2013?
Report abuse
Thank you.
Reported content has been submitted
Here's one way:
- Press Ctrl+H to open the Replace dialog.
- Select the Find tab.
- Type your search string into the "Find what" box.
- Click Find In and select Main Document.
- This will select all results.
- Click the title bar of the document to return focus to the document without deselecting the results.
- Press Ctrl+C to copy the selected text.
- You can then paste the results into another Word document (each result will be a separate paragraph) or an Excel sheet (each result will be a separate cell).
Fairhope, Alabama USA
http://ssbarnhill.com
http://wordfaqs.ssbarnhill.com
Screen shots captured with TechSmith's Snagit
Report abuse
Thank you.
Reported content has been submitted
24 people found this reply helpful
·Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
It's not at all clear what you want to copy, aside from whatever your search term is. For a possible solution, that outputs the sentence the found text occurs in, try:
Sub Demo()
Application.ScreenUpdating = False
Dim StrFnd As String, StrOut As String, Rng As Range
StrFnd = InputBox(Prompt:="String to Find")
If Trim(StrFnd) = "" Then Exit Sub
StrOut = "Sentences containing '" & StrFnd & "'" & vbTab & "page"
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Text = StrFnd
.Replacement.Text = ""
.Execute
End With
Do While .Find.Found
StrOut = StrOut & vbCr & .Sentences.Last.Text & vbTab & _
.Information(wdActiveEndAdjustedPageNumber)
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
StrOut = Replace(Replace(StrOut, Chr(12), ""), vbCr & vbTab, vbTab)
Set Rng = ActiveDocument.Range
With Rng
.Collapse wdCollapseEnd
.Text = StrOut
.ConvertToTable vbTab
With .Tables(1)
With .Rows(1)
.HeadingFormat = True
.Range.Font.Bold = True
End With
End With
End With
Application.ScreenUpdating = True
End Sub
Do be aware, though, that VBA has no idea what a grammatical sentence is. For example, consider the following:
Mr. Smith spent $1,234.56 at Dr. John's Grocery Store, to buy: 10.25kg of potatoes; 10kg of avocados; and 15.1kg of Mrs. Green's Mt. Pleasant macadamia nuts.
For you and me, that would count as one sentence; for VBA it counts as 5...
Paul Edstein
(Fmr MS MVP - Word)
Report abuse
Thank you.
Reported content has been submitted
8 people found this reply helpful
·Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Question Info
Last updated April 17, 2024 Views 10,648 Applies to: