+ Reply to Thread
Results 1 to 3 of 3

.xla ThisWorkbook module generates code on save

  1. #1
    Registered User
    Join Date
    01-12-2018
    Location
    Boise, ID
    MS-Off Ver
    2010
    Posts
    2

    .xla ThisWorkbook module generates code on save

    I have a custom add-in that I'm currently working on and recently I noticed that whenever I close down excel the add in will throw a compilation error out of the ThisWorkbook module from some code that I never put in and can't seem to delete. This is the code:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    With Application.CommandBars("Panels Manager")
    On Error Resume Next
    .Controls("

    End Sub

    Every time I delete this out and close excel then re-open this code gets regenerated. I hope to deploy this add-in to other users once it's complete and I can't have it throwing an error at everyone whenever they try to use excel with the add-in loaded.

    Any help is greatly appreciated,

    Thanks

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,263

    Re: .xla ThisWorkbook module generates code on save

    Are you saving the workbook as an add-in after you delete the code? s it possible that you are actually saving from a template so that it gets a new name?

    Also, it is possible that your file is corrupted. Try creating a new workbook and copying the sheets and code from the old workbook into the new, then deleting the old file completely.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    01-12-2018
    Location
    Boise, ID
    MS-Off Ver
    2010
    Posts
    2

    Re: .xla ThisWorkbook module generates code on save

    The add-in was created by starting from a new workbook and it has a ThisWorkbook module under the project in the VBE project toolbar. Here's a picture:

    vba_projecttoolbar_pmproject.JPG

    When I make the changes in VBE I save from within the editor then close down all of excel and the code is still there.

    I don't think it's corruption in a .xls file, because it seems to happen regardless of what workbook I have open. I don't think I'm saving from a template, but I'll check. There may be corruption in the add-in .xla file. I'll try to unload the add-in, create a new one and copy the old code into the new add-in and see if that does it (there's not a lot in the current add-in, anyway).

    Thanks for the quick response and for your suggestions!

+ 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. Code that generates a unique save path base on specific user
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2013, 08:54 AM
  3. ThisWorkBook.Path Generates an Error
    By Winon in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-22-2011, 10:41 AM
  4. Replies: 1
    Last Post: 08-30-2011, 02:23 AM
  5. Code in 'ThisWorkbook' module in add-in?
    By karan in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-04-2009, 03:36 AM
  6. Can I add code to ThisWorkbook module with VBA extensibility?
    By mikeb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2006, 11:15 PM
  7. Calls from sheet module to ThisWorkbook module
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-23-2005, 11:05 AM

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