+ Reply to Thread
Results 1 to 11 of 11

Changing worksheet CodeName generates error(s)

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,169

    Changing worksheet CodeName generates error(s)

    Reference: http://www.excelforum.com/excel-prog...-not-name.html

    I delete sheet1, copy sheet3, rename to sheet1 and then attempt to rename the CodeName to Sheet1 as well.
    This worked initially with out errors.

    Now on the first run of the macro it generates an error:
    Run-time error '32813':
    Method 'name' of object '_VBComponent' failed
    This fails to rename the CodeName of "Sheet1" (.Name)
    Run it again and it renames the CodeName but generates yet another error:
    Run-time error '-2147221080 (800401a8)':
    automation error
    FYI
    If you really need to know, a mild case of OCD drives me to do these things.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Changing worksheet CodeName generates error(s)

    Are you deleting the sheet with CodeName Sheet1, or a sheet named Sheet1? Look in the Project Explorer window.

    Also, you need to tick Trust access to the VB project
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,169

    Re: Changing worksheet CodeName generates error(s)

    Deleting Sheet1 which is both .Name and .CodeName "Sheet1", copying Sheet3, renaming to Sheet1 and then renaming CodeName to Sheet1.

    "Trust access to the VB project" is this under Tools, Macros, Security?

  4. #4
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Changing worksheet CodeName generates error(s)

    BTW, why are you worried so much about the code name anyway? I have an application where are deleted several sheets ans add a bunch or new ones and the codename just keeps having a higher number. There may be a limit somewhere, but I haven't hit it yet.

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,169

    Re: Changing worksheet CodeName generates error(s)

    I managed to climb over the OCD of this and going that route, but now Im curious too. LOL
    When I wrote the code it ran fine, several times. then it started generating errors.

  6. #6
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,169

    Re: Changing worksheet CodeName generates error(s)

    The automation error is not due to the CodeName change!
    It is generated by simple sheet renaming.
    Please Login or Register  to view this content.
    When I disable and enable displayalerts the automation error is generated.
    If I just go throught the "Prompts" of deleting the worksheet I do not get the automation error.

  7. #7
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Changing worksheet CodeName generates error(s)

    Hey, OCD, I think the link that shg gave said you had to know what you were doing :-)

  8. #8
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,169

    Re: Changing worksheet CodeName generates error(s)

    Doh!......

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,354

    Re: Changing worksheet CodeName generates error(s)

    FWIW, I can run that repeatedly (commenting out the form show bit) without error. Have you tried adding a DoEvents line before changing the codename in case it's a simple timing issue?
    Everyone who confuses correlation and causation ends up dead.

  10. #10
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Changing worksheet CodeName generates error(s)

    I commented out the if test on the active sheet and the form show stuff and can run it repeatedly. Excel2003.

  11. #11
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,169

    Re: Changing worksheet CodeName generates error(s)

    Quote Originally Posted by romperstomper View Post
    FWIW, I can run that repeatedly (commenting out the form show bit) without error. Have you tried adding a DoEvents line before changing the codename in case it's a simple timing issue?
    Thanks for the info.

+ 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