Modules calling code in other modules


Posted by John Berton on November 02, 2000 3:23 PM

I have a controlling module1 that calls a subroutine in module2.
It then calls a subroutine in module1 that deletes (successfully)
module2.
It then calls a subroutine in module1 that saves the spreadsheet. This all seems to work
fine except that the saved spreadsheet still has module2 in it.
After the modules are done running, if I manually save (ALT + FILE + SAVE) the
spreadsheet I get a saved version without module2. What's happening???



Posted by Ivan Moala on November 03, 2000 1:52 AM

I believe there is a time lag when doing this ??
Try putting in something like this in module1;

Sub Delay()
Application.OnTime Now + TimeValue("00:00:05"), "savenow"
End Sub

Sub SaveNow()
ThisWorkbook.Save
End Sub

Now in your deletion macro put in @ then end of
the routine a call to Delay which runs a short delay
before calling the save.......eg

Sub DeleteModule()
...........
...........
Application.Run "Delay"
End Sub

Ivan