Word
A family of Microsoft word processing software products for creating web, email, and print documents.
689 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello from Steve
1st Document has
JACK IN THE BOX
2nd document has
3. 42446 JACK IN THE BOX All(17-0-1-1) $10,240 L(9-0-0) R(8-0-2) Fm(0) G(3-0-0) Sf(7-0-0) H(7-0-2) Syn(0) C(3-0-0) Dst(4-0-1) Hdle(0) Stpl(0) (by Exploding Prospect )
Objective is to find JACK IN THE BOX in the second document then copy the whole paragraph as show'n above
Once copied go back to the first document then find Stakes : $[0-9]{1,} highlight the paragraph then paste.
Below please what is required please to switch to the second document
Yes I have both word documents open and are side by side "Spilt Screen".
Sub StakesToRaces2()
Application.ScreenUpdating = False
Do
Dim WordApp As Application
'Set WordApp = Word
Dim MyDoc1 As Document
Dim MyDoc2 As Document
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Stakes :"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=3
With Selection.Find
.Text = "[A-Z]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = True
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Extend
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found Then
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.Fields.Update
strText = Selection.Text
Selection.Collapse Direction:=wdCollapseStart
Selection.Find.ClearFormatting
Set MyDoc1 = WordApp.Documents.Add
With Selection.Find
.Forward = True
.Wrap = wdFindStop
.MatchCase = True
.MatchWholeWord = False
.Text = strText
.MatchWildcards = False
.Execute
End With
Selection.HomeKey Unit:=wdLine
Selection.Extend
Selection.EndKey
Selection.Copy
Selection.HomeKey Unit:=wdStory
Set MyDoc1 = WordApp.Documents.Add
With Selection.Find
.Text = "Stakes : $[0-9]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = True
Selection.Find.Execute
End With
Selection.Extend
Selection.EndKey
Selection.Paste
Selection.MoveDown Unit:=wdLine, Count:=1
End If
Loop While Selection.Find.Found
Application.ScreenUpdating = True
End Sub
This may be better asked over at the Microsoft 365 and Office Community
Please accept as an answer if this was helpful.
Hello from Steve
Hello Jordan M
I first posted in the community and then was advised to come to this site, I have now taken your advice and now posted it in Microsoft 365 and office Community.
I thank you.
All the Best