Results 1 to 9 of 9

VBA modules update creates duplicate entries

Threaded View

o3836002@rtrtr.com VBA modules update creates... 11-13-2012, 10:04 AM
arlu1201 Re: VBA modules update... 11-13-2012, 10:15 AM
Norie Re: VBA modules update... 11-13-2012, 10:26 AM
o3836002@rtrtr.com Re: VBA modules update... 11-13-2012, 10:39 AM
Norie Re: VBA modules update... 11-13-2012, 10:43 AM
o3836002@rtrtr.com Re: VBA modules update... 11-13-2012, 10:45 AM
Kyle123 Re: VBA modules update... 11-13-2012, 10:46 AM
Norie Re: VBA modules update... 11-13-2012, 11:04 AM
o3836002@rtrtr.com Re: VBA modules update... 11-13-2012, 11:22 AM
  1. #1
    Registered User
    Join Date
    11-13-2012
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    12

    VBA modules update creates duplicate entries

    Hello together,

    I'm trying to update an existing VB module in an excel sheet. My code is as simple as this

    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
    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.

    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.
    Last edited by arlu1201; 11-13-2012 at 10:14 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1