+ Reply to Thread
Results 1 to 6 of 6

Delete Module In Another Workbook Problem

  1. #1
    Forum Contributor
    Join Date
    04-23-2015
    Location
    UK
    MS-Off Ver
    2010
    Posts
    100

    Delete Module In Another Workbook Problem

    Hi,
    I open the Project workbook, and when conditions are met, a copy
    of that workbook is made (UserWkbk).
    So I now have two workbooks open.
    The Project workbook code then calls the following sub:

    Please Login or Register  to view this content.
    I'm getting a subscript out of range error msg on the line:
    Set VBComp .....

    Can you help, please ?

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Delete Module In Another Workbook Problem

    Not sure about this, but, could it be the s at the end of components? In your declaration there is no s in component.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Contributor
    Join Date
    04-23-2015
    Location
    UK
    MS-Off Ver
    2010
    Posts
    100

    Re: Delete Module In Another Workbook Problem

    Thanks - well spotted.

    After correcting, I now get:

    "Object doesn't support this property or method"

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Delete Module In Another Workbook Problem

    Did you remove the s from both components?

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Delete Module In Another Workbook Problem

    Hello stuartgb100,

    Your code syntax is correct as you first posted. The error is saying there is no VBComponent named "InitialiseOnOpenWorkbook" in the VBProject.

    There are four basic types of VBComponents: Class Modules, Documents (These are Sheets), UserForms, and Standard Modules. Judging by the name used, I suspect you are trying to remove code from a worksheet.

    It would help if you would explain in more detail what it is you wish to accomplish. Once I know what you want to do, I can help your more.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Forum Contributor
    Join Date
    04-23-2015
    Location
    UK
    MS-Off Ver
    2010
    Posts
    100

    Re: Delete Module In Another Workbook Problem

    gmr4evr1 - yes both 's' removed.

    Leith, I am trying to delete a module named 'InitialiseOnOpenWorkbook'
    This module is in a different workbook from the workbook doing the deletion.

    I have discovered the problem - as you say, there is no such module found.

    What I was trying to achieve, is as follows:

    1. use vba to create a copy of the Project workbook
    2. delete that particular module from the copy
    3. save the copy

    This is the copy code:

    Please Login or Register  to view this content.
    and then we move to the DeleteModule sub as first posted.

    Just discovered that the copy workbook is named currently as Book1.
    It seems as though it has worksheet code, but there are no modules and no
    ThisWorkbook code - hence the subscript out of range error message.

    Do I have to save this copy as a '.xlsm' filetype before I go any further with deleting that module ?

    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Can't reference ThisWorkbook from a module in another workbook module
    By Bukovnik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-11-2015, 11:32 AM
  2. Compile error in hidden module: Module 1 when workbook opened on different machine!?
    By MathUKTeacher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2015, 04:38 PM
  3. [SOLVED] Delete Form, Module and This Workbook code (Run Once)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2014, 12:11 PM
  4. copy module and past module in new workbook
    By flunzy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2013, 04:33 AM
  5. Run worksheet module code from workbook module?
    By keithb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2005, 12:05 AM
  6. [SOLVED] re: Automatically Delete WorkBook 2 modules by using Workbook 1 module
    By ddiicc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-27-2005, 08:05 AM
  7. Replies: 0
    Last Post: 06-21-2005, 01:05 PM

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