Thema Weiterbildung! Ich taste mich peu à peu mit den VBComponents und Co. Habe etliche Proficodes gefunden die mich etwas überfordern. Ich möchte (momentan) lediglich ein neues Modul mittels VBA generieren im untenstehenden Beispiel.
Wer könnte mir weiter helfen?
Sub Uebertrage_Module()
Dim sSOURCE As String, sTARGET As String
sSOURCE = "QUELLE.XLS"
sTARGET = "ZIEL.XLS"
Call CopyCode(sSOURCE, sTARGET, "DieseArbeitsmappe")
Call CopyCode(sSOURCE, sTARGET, "DECLARATIONS")
Call CopyCode(sSOURCE, sTARGET, "C_COMBOXES")
Call CopyCode(sSOURCE, sTARGET, "MAIN")
End Sub
Sub CopyCode(sSOURCE, sTARGET, sMODULNAME)
'Gefunden im Forum von Office-Lösungen - Autor: Nepumuk
Dim objCodeModule As Object
Set objCodeModule = Workbooks(sSOURCE).VBProject.VBComponents(sMODULNAME).CodeModule
'if CodeModule nicht vorhanden dann stelle ein leeres Modul zur Verfügung
With Workbooks(sTARGET).VBProject.VBComponents(sMODULNAME).CodeModule
.DeleteLines 1, .CountOfLines
.InsertLines 1, objCodeModule.Lines(1, objCodeModule.CountOfLines)
End With
MsgBox (sMODULNAME & " wurde erfolgreich aktualisiert.")
End Sub
Mahlzeit!
Franz D.