Greetings,
I can do a singular find & replace in multiple docs. How do I use the select case? I have 7 bits to search & replace and would like to learn to use the select case.
Thanks
Nikka
Dim oDocument As Document
Sub ReplaceTemplatesFPwithClauses()
'Search all open documents
Dim oDocument As Document
For Each oDocument In Application.Documents
If Not oDocument = ThisDocument Then
oDocument.Select
MsgBox oDocument.Name
'Find and Replace code here
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Select Case ReplaceClauses
Case "Court Address"
With Selection.Find
.Text = _
"%[Templates.Select('\AA Automated Common\~SubTemplates', '4. Court Office Address.rtf')]"
.Replacement.Text = _
"%[Clauses.Select(""\AA Automated Common\Insert SubTemplates"", ""Court Address""
]"
End With
Case "Licenced Firm Name"
With Selection.Find
.Text = _
"%[Templates.Select('\AA Automated Common\~SubTemplates', '2. Licenced Firm Name.rtf')]"
.Replacement.Text = _
"%[Clauses.Select(""\AA Automated Common\Insert SubTemplates"", ""Licenced Firm Name""
]"
End With
End Select
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceAll
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
End If
Next
End Sub
I can do a singular find & replace in multiple docs. How do I use the select case? I have 7 bits to search & replace and would like to learn to use the select case.
Thanks
Nikka
Dim oDocument As Document
Sub ReplaceTemplatesFPwithClauses()
'Search all open documents
Dim oDocument As Document
For Each oDocument In Application.Documents
If Not oDocument = ThisDocument Then
oDocument.Select
MsgBox oDocument.Name
'Find and Replace code here
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Select Case ReplaceClauses
Case "Court Address"
With Selection.Find
.Text = _
"%[Templates.Select('\AA Automated Common\~SubTemplates', '4. Court Office Address.rtf')]"
.Replacement.Text = _
"%[Clauses.Select(""\AA Automated Common\Insert SubTemplates"", ""Court Address""
End With
Case "Licenced Firm Name"
With Selection.Find
.Text = _
"%[Templates.Select('\AA Automated Common\~SubTemplates', '2. Licenced Firm Name.rtf')]"
.Replacement.Text = _
"%[Clauses.Select(""\AA Automated Common\Insert SubTemplates"", ""Licenced Firm Name""
End With
End Select
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceAll
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
End If
Next
End Sub