Ich konnte das Problem selber Lösen mit diesem Code in einem neuen Modul:
Sub AutoNew()
Dim oDoc As Document
Set oDoc = ActiveDocument
UpdateVBACode oDoc, "ThisDocument"
lbl_Exit:
Set oDoc = Nothing
Exit Sub
End Sub
Function UpdateVBACode(oDoc As Document, strModule As String) As Boolean
Dim oSource As Document
Dim strLines As String
Dim i As Long, j As Long
Set oSource = ThisDocument
i = oDoc.VBProject.VBComponents(strModule).CodeModule.CountOfLines
oDoc.VBProject.VBComponents(strModule).CodeModule.DeleteLines 1, i
With oSource.VBProject.VBComponents(strModule).CodeModule
strLines = .Lines(1, .CountOfLines)
oDoc.VBProject.VBComponents(strModule).CodeModule.AddFromString strLines
End With
lbl_Exit:
Set oSource = Nothing
Exit Function
End Function
Ich hoffe mit dem kann ich noch jemanden anderem helfen.
Gruss
Lukas
|