Re: VBcomponent: Remove Before Close
A co-worker had the same problem and asked me for help. His code attempted to remove an old code module and then import a new version with the same name. This resulted in the problem that you describe. By trial and error we noted that the old code module was not being deleted when the Remove command was executed so the subsequent Import step didn't work correctly. But we also noted that the old code module was being deleted at the end of the procedure containing the Remove step. So our solution (for which we have no technical explanation) was to put the Remove step and the Import step into different procedures. His original code made use of a macro button that called a macro procedure to perform both the Remove and Import. We substituted a command button for the macro button. In the command button's click event we added 2 calls. The first call executed a Sub that performed the Remove and ended. When this Sub ended, the old code module was deleted. The second call executed a Sub that performed the Import. This seemed to solve the problem.