+ Reply to Thread
Results 1 to 4 of 4

Issue Deleting Module Using Macro

  1. #1
    Registered User
    Join Date
    08-26-2014
    Location
    Edmonton, Alberta, Canada
    MS-Off Ver
    2010
    Posts
    4

    Angry Issue Deleting Module Using Macro

    I have this macro that is causing me nothing but headaches. I have been at it for 24 hours now. I have a workbook to perform maintenance called "Quote Log Maintenance Macros". It has to loop through many workbooks (60ish) and replace a module called utilities. What I get is that sometimes it works and other times it wont. It seems there is a problem if I save and close the workbook using vba code. That means if I set my constant LIVE to "False" it usually works because the macro ends and I do the save and close. If I launch my testing launch point "Sub TestUpdate94" it usually works. However if I try to run the main function "Function Update94" it through the loop (as it should) it runs 20% of the time or less.

    I have added the Microsoft Visual Basic for Applications Extensibility 5.1

    I have tried all kinds of weird things to make it work. I tried to change the name of the module before I delete it. That seemed to help so it doesn't bring in "Utilities1" instead of "Utilities". Looped through to delete the module 100 times. That made little difference. Added extra calculates. Made sure events are enabled. Activated the workbook over and over again to make sure it is the active one.

    I am at a loss. It shouldn't be that hard. Delete Utilities Module. Import new utilities module. Done. What is it that I am missing? Some events don't seem to be firing right.
    Do I need to use a personal macro workbook or something? Is there a secret to using vba to make changes to a macro module?

    Thank you!
    Attached Files Attached Files
    Last edited by benoitjolin; 12-10-2014 at 02:18 PM. Reason: Seems to be linked to using vba to save.

  2. #2
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Issue Deleting Module Using Macro

    Maybe...
    http://www.ozgrid.com/VBA/delete-module.htm
    http://www.cpearson.com/excel/vbe.aspx
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  3. #3
    Registered User
    Join Date
    08-26-2014
    Location
    Edmonton, Alberta, Canada
    MS-Off Ver
    2010
    Posts
    4

    Re: Issue Deleting Module Using Macro

    I have read through these and many other threads. The code I implemented is from there. The main issue still remains that if I let the macro save and close the workbook for me, I get unpredictable results like the module is not deleted when I open the book. I have to end the code and manually perform a save for it to work right.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Issue Deleting Module Using Macro

    You may want to try a slightly different approach:
    a. Do everything exactly as you did before but do not save the modified workbook.
    b. Create a new Workbook.
    c. Copy resources from the modified workbook to the new workbook.
    d. Close the original workbook that was modified without saving.
    e. Save the new workbook.

    Lewis

+ 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] Deleting module to another Workbook
    By artiko in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2013, 03:29 PM
  2. Macro issue deleting input data
    By smiteme in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2012, 10:50 AM
  3. Replies: 2
    Last Post: 03-27-2009, 11:48 AM
  4. [SOLVED] programming VBE -> Deleting All Code From A Module
    By pm in forum Excel General
    Replies: 4
    Last Post: 12-30-2005, 09:25 PM
  5. [SOLVED] programming VBE -> Deleting All Code From A Module
    By pm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-30-2005, 09:25 PM

Tags for this Thread

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