1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Sub EcrireDuCodeDansUnModule()
Dim i, nomFich, x As Long, NomWorkbook
nomFich = ActiveWorkbook.Name 'Nom du classeur résultat
NomWorkbook = ThisWorkbook.Name 'Nom du classeur origine
For Each LeModule In ActiveWorkbook.VBProject.VBComponents
MsgBox LeModule.Name
If LeModule.Name = "ThisWorkbook" Then
x = LeModule.CodeModule.CountOfLines
LeModule.CodeModule.InsertLines x + 1, "Private Sub Workbook_Activate()"
LeModule.CodeModule.InsertLines x + 2, " Run """ & NomWorkbook & """ & ""!CacherUserForm"""
LeModule.CodeModule.InsertLines x + 3, "End sub"
End If
Next
End Sub |