View Single Post
 
Old 10-03-2023, 04:16 PM
Dave T Dave T is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Nov 2014
Location: Australia
Posts: 66
Dave T is on a distinguished road
Default

Hello East,
I can’t thank you enough.

I had been trying to work out the wildcard combinations for quite a while, without success.
I had worked out breaking the parts within brackets and had the first part (No restrictions apply), but the second part where it may or may not have an existing full stop/period had me stumped. Not being that familiar with the use of wildcard characters was where I was stuck and I must admit I did not fully understand the use of the exclamation character ([!.]).
After struggling with the wildcards option, I then thought I would try another approach and find the specific word/s in a paragraph and delete the entire paragraph and replace it with what I was after.
That way if the line contained a full stop/period on not it would delete the entire line and replace it with what I was after.
I found a reply by Greg Maxey to another post and edited this to suit my needs (link in code).
Code:
Sub Add_Full_Stop_After_apply()
  'https://www.msofficeforums.com/word-vba/45779-how-i-add-missing-stop-period-end.html
  
  Dim oRng As Range
  
  Set oRng = ActiveDocument.Range
  With oRng.Find
    '.Text = "[!.\!\?]" & Chr(13)
    .Text = "[apply]" & Chr(13)
    .MatchWildcards = True
    While .Execute
    oRng.Select
    oRng.Start = oRng.Start + 1
    oRng.InsertBefore "."
    oRng.Collapse wdCollapseEnd
  Wend
End With
End Sub
Now I have two options to use.
I appreciate your reply and helping me gain a better insight into the use of wildcards.
Regards, Dave T.
Reply With Quote