Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case Find and Replace Multi Docs?

Status
Not open for further replies.

nikka

Instructor
Mar 11, 2001
36
ZA
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top