+ Reply to Thread
Results 1 to 2 of 2

Delete modules in another file

  1. #1
    MikeP
    Guest

    Delete modules in another file

    I am having trouble running a macro that deletes a module in another
    file. The script I'm using is:

    Sub DeleteModules()
    Dim VBComp As VBComponent

    Set VBComp = ThisWorkbook.VBProject.VBComponents("Module2")
    ThisWorkbook.VBProject.VBComponents.Remove VBComp

    End Sub

    Before I run the macro I activate a tab within the desired workbook.
    Any idea why this is giving me a subscript out of range error?


  2. #2
    Bernie Deitrick
    Guest

    Re: Delete modules in another file

    Mike,

    You'll need to change both instances of

    ThisWorkbook

    to

    ActiveWorkbook


    HTH,
    Bernie
    MS Excel MVP


    "MikeP" <[email protected]> wrote in message
    news:[email protected]...
    >I am having trouble running a macro that deletes a module in another
    > file. The script I'm using is:
    >
    > Sub DeleteModules()
    > Dim VBComp As VBComponent
    >
    > Set VBComp = ThisWorkbook.VBProject.VBComponents("Module2")
    > ThisWorkbook.VBProject.VBComponents.Remove VBComp
    >
    > End Sub
    >
    > Before I run the macro I activate a tab within the desired workbook.
    > Any idea why this is giving me a subscript out of range error?
    >




+ Reply to Thread

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