+ Reply to Thread
Results 1 to 6 of 6

module name changes on it's own

  1. #1
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108

    module name changes on it's own

    I am stumped.

    I have an auto_open macro that (with help from a number of people on this forum) I now have self-maintaining.

    If a flag in the workbook is set to "Y" then the module (that also contains the auto_open) is removed and a new version is imported.
    This works. A treat.

    The problem is that SOMETIMES (well - often) the newly importing module name has a "1" added to it.

    So module deleted might be FRED.
    Module loaded is FRED.
    Module name is set to FRED1.

    Of course, next time someone loads new version it cannot find FRED (as it is now called FRED1).

    Can anyone point me in the direction of the problem?

    Thanks in advance.
    Tony

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What code are you using? Is it deleting Fred before adding the new code?

    Why can't you codee just edit the existing module?

    a link to your previous post might help.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108
    I've a sneaking suspicion I may have worked it out.
    In non-technical terms this is what I think is happening ...

    FRED is a module.
    Within FRED there is an AUTO_OPEN procedure wheich checks a flag on the spreadsheet and if the flag is "Y" it then removes the module FRED and imports FRED from a file (the location of which is also specified on the spreadsheet).

    I think that FRED is being executed so when FRED is imported, it cannot be called FRED as FRED is executing at that timem so Excel helpfully calls it FRED1.

    The code, in case it helps people much more skilled than I, I use to do this is as follows ...

    Please Login or Register  to view this content.
    The variables used above are ...
    vReloadCodeOnStartup = the flag to decide whether new load is required.
    vFileContainingModule = The file name where the new version can be found
    vModuleToLoad = the module name (e.g. FRED)

    ANY comments on this welcome.
    BTW - the module is not really called FRED (in case it matters), I've changed the name to protect company confidentiality.

    I guess I could rename the "old" module prior to removal - would that do it?
    If so - how would I rename it?

    Again - thanks very much for your help.

  4. #4
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108
    Can anyone tell me how I can use VBA to rename a module?

    Thanks

  5. #5
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi tonywig

    How about :
    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  6. #6
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108
    Thanks Dominic

+ 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