Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 01-11-2022, 06:19 PM
Mr J Mr J is offline Looking for VBA code that can FIND and SELECT any text based on its properties Windows 10 Looking for VBA code that can FIND and SELECT any text based on its properties Office 2016
Novice
Looking for VBA code that can FIND and SELECT any text based on its properties
 
Join Date: Aug 2020
Location: California, US
Posts: 15
Mr J is on a distinguished road
Default

Here is the coding I have per step listed in the original post.

Step 1:
Sub CombineAllWordDocs()
Dim baseDoc As Document, sFile As String
Dim oRng As Range
On Error GoTo err_Handler
Set baseDoc = Application.Documents.Add
sFile = Dir(sPath & "*.doc")
'Loop through all .doc files in that path
Do While sFile <> ""
Set oRng = baseDoc.Range
oRng.Collapse wdCollapseEnd
oRng.InsertFile sPath & sFile
Set oRng = baseDoc.Range
oRng.Collapse wdCollapseEnd
oRng.InsertBreak Type:=wdSectionBreakNextPage
sFile = Dir
DoEvents
Loop
MsgBox "Process complete"
lbl_Exit:
Set baseDoc = Nothing
Set oRng = Nothing
Exit Sub
err_Handler:
MsgBox Err.Number & vbCr & Err.Description
Err.Clear
GoTo lbl_Exit
End Sub


Step 2:
Sub Remove_Enter()
'
' Remove_Enter Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Step 3:
Missing Step


Step 4:
Sub Extract_Highlighted_Text()
'
' Extract_Highlighted_Text Macro
'
'

Debug.Print oNum 'This is the output list

Dim oDoc As Document
Dim s As String
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = ""
.Highlight = True
Do While .Execute
s = s & Selection.Text & vbCrLf
Loop
End With
End With
Set oDoc = Documents.Add
oDoc.Range.InsertAfter s

End Sub


Step 5:
Copy and Paste to Excel
Reply With Quote
 

Tags
macro find text, select text, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro/VBA code to select ALL text in a textbox in microsoft excel and add a new row jyfuller Excel Programming 11 06-01-2015 08:49 PM
Macro to select an { includepicture } field code and format the picture behind text and 100% scale sanpedro Word VBA 3 03-30-2015 10:50 PM
Microsoft Word macro to find text, select all text between brackets, and delete helal1990 Word VBA 4 02-05-2015 03:52 PM
Looking for VBA code that can FIND and SELECT any text based on its properties VBA code for Microsoft Word macro — select text and insert footnote ndnd Word VBA 10 01-06-2015 01:47 PM
Looking for VBA code that can FIND and SELECT any text based on its properties How to find and select text in a document? mkhuebner Word VBA 8 02-04-2014 08:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:06 PM.


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