Hello,
Voici une procédure pour insérer du code dans un module et un classeur connu.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Public Sub InsertCode(ByVal Classeur As String, _
ByVal Modul As String, _
ByVal ProcCode As String)
Dim wb As Workbook
Dim md As VBIDE.CodeModule
Dim i As Long
Set wb = Workbooks(Classeur)
Set md = wb.VBProject.VBComponents(Modul).CodeModule
md.AddFromString ProcCode
Set md = Nothing
Set wb = Nothing
End Sub |
j'ai testé, ça semble marcher :
InsertCode "Feuil4","Module1", GetProcCode("Foutoir.xls","UnModule","UneProc")
edit : Module est un mot clé
Partager