"VK" <"myname"@example.invalid> wrote in message
news:3fm4vgF8gch8U1@news.dfncis.de...
> > If it is an event macro, use something like
> >
> > Dim iStartAs Long
> >
> > With
ActiveWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
> > iStart = .CreateEventProc("BeforeSave", "Workbook") + 1
> > .InsertLines iStart, _
> > "Dim ans" & vbCrLf & _
> > " ans = Msgbox( ""All OK"",vbYesNo)" & vbCrLf & _
> > " If ans = vbNo Then Cancel = True"
> > End With
> >
> > If it just another macro in Module1 say, then use
> >
> > Dim iNext As Long
> >
> > With ThisWorkbook.VBProject.VBComponents("Module1").CodeModule
> > iNext = .CountOfLines + 1
> > .InsertLines iNext, _
> > "Sub myProc()" & vbNewLine & _
> > " Msgbox ""Tesing new procedure"" " & vbNewLine & _
> > "End Sub"
> > End With
> >
>
> Thanks! I'll try it out
> Reg. VK
Would like todo same with about 5 multi-page routines, so wonder if instead
of embedding the new code in the copying macro (per above), if its possible
to copy an existing macro between files, say from personal.xls to book1.xls
??
ie:
Sub test()
Workbooks("Book1").VBProject.VBComponents.Import _
(Workbooks("Personal").VBProject.vbcompoents("aging_report").codemodule)
End Sub
seems logical, but returns "runtime error 438: object does not support this
property or method"
Bookmarks