Hello together,
I'm trying to update an existing VB module in an excel sheet. My code is as simple as this
So I remove it if it is present and import it afterwards. If I run the macro from within the VBE everything works as expected. For convenience I created a menu entry which calls that macro. If I start it this way I end up having just one Module named "Globals1" at first. So it seems that the remove didn't work. Another click generates the correct "Globals" entry but then I have tow modules and everything crashes.![]()
For Each m In ThisWorkbook.VBProject.VBComponents If m.name = "Globals" Then ThisWorkbook.VBProject.VBComponents.Remove m End If Next Set k = ThisWorkbook.VBProject.VBComponents.Import("c:\Globals.bas") DoEvents
Any ideas how I can solve this? It is kind a interesting that some other modules I try to import the same way work flawlessly. I also tried some wait statements to pause the macro for a second but also no success. Even without the for-each I end up having a "globals1" first. Really crazy!
Thanks!
Moderator's Edit: Use code tags when posting code. To do so in future, select your code and click on the # icon at the top of your post window.
Bookmarks