+ Reply to Thread
Results 1 to 15 of 15

method 'location' of object '_Chart' failed.

  1. #1
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9

    method 'location' of object '_Chart' failed.

    Hi,

    I'm currently working on a fairly complex VBA project in Excel 2007. Basically though, I'm downloading information from a site, massaging it, creating a lot of graphs, saving them locally, deleting the chart from excel. I then save a copy of the workbook to a local file, clear the Spreadsheet, and then Do the same for information from another site.

    When I had all of the code in one Module and ran it as a macro it ran flawlessly.

    Now i've put the information into a Class. And am pretty much running the same process via a UserForm.

    The problem I have though is that at any point after I execute the code: (and please assume that all variables have been declared, because they have)

    Please Login or Register  to view this content.
    I can no longer use this statement when moving a chart:


    Please Login or Register  to view this content.
    Even though I have created the chart and added it to the sheet and peformed various other operations on it by referencing ActiveChart

    The Problem seems to lie in the Location method.

    If I never "SaveCopyAs" then All the code runs fine, its just that as soon as I SaveCopyAs I can no longer change the location of a Chart:

    If I debug the project I receive the error: run-time error 1004 - method 'location' of object '_Chart' failed.
    at runtime. (If I then click "End") I get a File/Path Error, and then sometimes Excel crashes.

    If I run the project as any user would, I receive the run-time error:

    Error -2147417848 (&H80010108): The object invoked has disconnected from its clients.
    And then Excel Crashes "Microsoft Office Excel has encountered a problem and needs to close. .... "

    Any ideas on how to fix this? I'm assuming that after I saveCopyAs its losing a reference to something, and I've tried many things to fix this problem... all to no avail.

    Please help,
    Thanks,
    Last edited by Hendel; 10-29-2008 at 01:06 PM. Reason: RESOLVED

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    You will probably get limit response here, as you did at MSDN, because the problem is specific to your set of files and processes.

    The code that is causing you problems does not in itself cause and error.
    By that I mean if we take the very small code sample and test it there is no error and things behave as expected.

    That would suggest the problem is somewhere else in you complex project.

    What you have to do to help us help you is break your processing down so you can post a small example of code and data and still demonstrate the problem. A pain I know but without taking these steps we probably will not be able to suggest anything helpful.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9
    Quote Originally Posted by Andy Pope View Post
    What you have to do to help us help you is break your processing down so you can post a small example of code and data and still demonstrate the problem. A pain I know but without taking these steps we probably will not be able to suggest anything helpful.

    I'll try to create a small sample program that duplicates the error.

  4. #4
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9
    Okay, I've recreated the problem with a relatively simple program:
    This program is in 3 parts:
    1) A Module :"Module 1"
    2) A UserForm: "UserForm1"
    3) A Class: "Graphing"

    Code in Module 1:
    Please Login or Register  to view this content.
    Code in UserForm1
    Please Login or Register  to view this content.
    Code in Graphing
    Please Login or Register  to view this content.
    Okay in Sheets1 I have values in a1 through b13 (this is where the graph grabs its values from)
    A B
    0 43
    1 73
    2 22
    3 34
    4 22
    5 76
    6 74
    7 45
    8 73
    9 34
    10 72
    11 52
    12 32

    If you throw in a code break and follow the code, it fails at the same part as in my program: which is at the location method.

    any help would be greatly appreciated

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    I just built a workbook as per your instructions and it runs without error.

    Have you run a detect and repair on your Excel installation?

  6. #6
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9
    Quote Originally Posted by Andy Pope View Post
    I just built a workbook as per your instructions and it runs without error.

    Have you run a detect and repair on your Excel installation?
    That's crazy. I'll run a detect and repair, and try and have a co-worker run the program as well on their comp to see if they get an error.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    Here is the workbook I built. See if this errors for you.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9
    Quote Originally Posted by Andy Pope View Post
    I just built a workbook as per your instructions and it runs without error.

    Have you run a detect and repair on your Excel installation?

    If you run it in Debug mode what happens?
    So basically, go to Module 1, and the method, and then hit the green arrow, does it fail then?

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    I can run from Macro dialog or VBE without failure.
    I can step through each line or let it run no failure.

  10. #10
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9
    Quote Originally Posted by Andy Pope View Post
    I can run from Macro dialog or VBE without failure.
    I can step through each line or let it run no failure.
    I used your program and ran it in debug mode and it failed.

    I edited my program so it ALWAYS fails on running, it fails on my co-workers computer as well. I've attached the file.

    p.s. Thanks for your time!
    Attached Files Attached Files

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    Again, not problems with your example file.

    Do you have SP1 installed?

  12. #12
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9
    Quote Originally Posted by Andy Pope View Post
    Again, not problems with your example file.

    Do you have SP1 installed?

    Are you running it from Vista?
    I'm running it from XP with SP2 and everything up to date...

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    Yes I have Vista.

    The SP1 was in reference to Office service pack rather than the OS's

    If I get change tonight, before football, I will try XP/XL2007 environment.

  14. #14
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9
    hopefully I'll have it resolved by then, now that I know it is not a code problem.
    HA! figured out I didn't have SP1 installed.
    after it downloads I'll let you know if that resolves the issue.
    Thanks,

  15. #15
    Registered User
    Join Date
    10-24-2008
    Location
    USA
    Posts
    9
    Installing SP1 solved the issue.
    FINALLY, its so good to know it wasn't a coding problem but a MS problem.

    I'm glad MS doesn't make pacemakers.

    to quote a co-worker: hey sire , we are experiencing an issue with your pace maker...it needs SP1

    thanks for the Help ANDY
    Last edited by Hendel; 10-29-2008 at 01:06 PM.

+ 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