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
|
Sub RemplacementMotDansProcedure1()
'Nécéssite d'activer la référence
'"Visual basic For Application Extensibility 5.3"
'
Dim oVBC As VBComponent
Dim oWB As Workbook
Dim Ancien As String, Nouveau As String, Cible As String
Dim i As Long
Set oWB = Workbooks("MomClasseur1.xls")
Ancien = "Feuil3"
Nouveau = "Feuil1"
For Each oVBC In oWB.VBProject.VBComponents
If oVBC.Name <> "modRemplacement" And _
oVBC.CodeModule.Find(Ancien, 1, 1, -1, -1) Then
With oVBC.CodeModule
For i = 1 To .CountOfLines
If InStr(1, .Lines(i, 1), Ancien, vbTextCompare) Then
Cible = Replace(.Lines(i, 1), Ancien, Nouveau, , , vbTextCompare)
.ReplaceLine i, Cible
End If
Next i
End With
End If
Next oVBC
Set oVBC = Nothing
Set oWB = Nothing
End Sub |
Partager