Consulting

Results 1 to 9 of 9

Thread: 2003 to 2007 code transfer trouble

  1. #1

    2003 to 2007 code transfer trouble

    I created a workbook in 2003 and sent it to another to be used in their 2007 version. When she executes the command button in the 2007 version, she gets a runtime error: '-2147024809(80070057)': The item with the specified name wasn't found. Choose 'debug' and the row: ActiveSheet.Shapes("Button 8").Select - is highlighted.
    It works fine in 2003 - not in 2007. I resent the workbook and the exact same error came up.

    Any ideas on how to have this transfer from 2003 to 2007 properly?

    Thanks so much.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I have just created a simple workbook with a button and activeated that in the Workbook_Open routine, then opened the workbook in Excel 2007, and it worked fine.

    There must be something else going on. Can you post the workbook?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    do paste that worksheet..to test

  4. #4

    Attaching Workbook

    Attachment 9945

    have at it. Sheet "423a 121" is the one that comes up with the run time error in 2007 only; not 2003.

    Anxiously awaiting your reply...

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Go to the Developer tab, go into Design Mode, right click the button, and the name will show in the Name Box to the left of the formula bar

    Comes back with "Button 1"

    Changing the offending line to

    [vba]
    ActiveSheet.Shapes("Button 1").OnAction = "Clear423a121"
    [/vba]

    works (no need to Select everything first)


    Paul

  6. #6
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    220
    Location
    When you run your clear sheet routine for some reason excel is changing your Button 8 to Button 1 this happens on the first two sheets?
    "Intellectual passion occurs at the intersection of fact and implication."

    SGB

  7. #7
    I am working in 2003. When I change the button to "Button 1" as you have suggested below, it doesn't work. When it's changed to "Button 8" it does...

    Are you in version 2003 or 2007? I don't have 2007 to test from so I don't know if this executes properly in that or other versions.

  8. #8
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    220
    Location
    Excel 2007 changes the names of your copied sheet buttons. 423a 04 Blank which has Button11 becomes Button 1. Sheet 423a 221 Blank which has Button 8 also changes to Button 1.

    Using the name dialog box select the controls and change the names of the buttons on the visible sheets to Button 1 and on the hidden sheets that are copied to Button 1 then make the changes in the code from Button 8 to Button 1.
    "Intellectual passion occurs at the intersection of fact and implication."

    SGB

  9. #9
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Well another way would be to loop through the shapes and look for the text.

    That would give you the button you want, and then you could set things, etc.

    The function example below is not very general purpose, but could easily be expanded

    Change your one line to use the results of a function, and then define the funtion to return a Shape

    Paul

    [vba]

    ..........

    If Not TheButton Is Nothing Then TheButton.OnAction = "Clear423a121"



    Function TheButton() As Shape
    Dim shpButton As Shape
    For Each shpButton In ActiveSheet.Shapes
    If Left(shpButton.AlternativeText, 5) = "CLEAR" Then
    Set TheButton = shpButton
    Exit Function
    End If
    Next
    Set TheButton = Nothing
    End Function
    [/vba]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •