-
Notifications
You must be signed in to change notification settings - Fork 3
/
TCEntryReplacementCHILD-SingleReplaceAll
43 lines (33 loc) · 1.31 KB
/
TCEntryReplacementCHILD-SingleReplaceAll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Function SingleReplaceAll(sTexttoSearch As String, sReplacementText As String)
'============================================================================
' Name : SingleReplaceAll
' Author : Erica L Ingram
' Copyright : 2019, A Quo Co.
' Call command: Call SingleReplaceAll(sTexttoSearch, sReplacementText)
' Description : one replace TC entry function for ones with no field entry
'============================================================================
Dim oWordApp As Object, oWordDoc As Object
Dim sFileName As String
Set oWordApp = GetObject(, "Word.Application")
sFileName = "T:\In Progress\" & vCourtDatesID & "\" & vCourtDatesID & "-CourtCover.docx" 'file name to do find/replaces in
oWordApp.Visible = False
Set oWordDoc = oWordApp.Documents.Add(sFileName)
With oWordDoc.Application
.Selection.Find.ClearFormatting
With .Selection.Find
.Text = sTexttoSearch
.Replacement.Text = sReplacementText
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
While .Selection.Find.Found
.Selection.Find.Execute Replace:=wdReplaceAll
Wend
End With
End Function