+ Reply to Thread
Results 1 to 21 of 21

problem Automation Error

  1. #1
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    problem Automation Error

    Similar to the problem

    here, I receive an automation error, when using this code, the debugger is marking the line with n =...

    Please Login or Register  to view this content.
    Would be great if someone can help!

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    Do you still get the error if you use:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    Yes, the error still occurs.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    Are you running this in Excel? If so, which version?

  5. #5
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    Yes, in Excel, the Version is 2002, SP3

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    OK, a few more questions:
    1. When you used my first correction, did the error still occur on the same line, or did it occur on the m = ... line?
    2. How are n and m declared?

  7. #7
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    1. Now the debugger highlights "With WB.Worksheets(1)"
    2. n and m are not declared

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    Weird. Do you have any worksheets (as opposed to chart sheets) in the workbooks? What sort of files are you opening? (Are WB and WB2 declared as Workbooks?)

  9. #9
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    It surprises me as well.

    WB and WB2 are both declared as Workbooks. Both of them are Worksheets filled with data. And both of them are not the file with the vba-code in them. The Chart is supposed to be saved in the GUI, where also the vba-code is.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    Does this version work:
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    Sorry, have to revise... It still does not work and shows the same error, same line as before
    Last edited by RoyMakaay1985; 06-17-2009 at 03:50 AM.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    I cannot replicate that behaviour. Any chance you could post the files in question for testing?

  13. #13
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    Here is the full code, this is in the GUI, where the user selects two files (Quelldatei, Quelldatei 2) and then clicks Button11:

    Please Login or Register  to view this content.

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    It would appear you did not use the code as I posted it:
    Please Login or Register  to view this content.
    should be:
    Please Login or Register  to view this content.
    Note the two periods before the two instances of the word Rows - they must be there.

  15. #15
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    Hm, you are right about that. However, the error is still in the same line after adding the periods. The fault message, to add that, says "Runtime error '-2147221080 (800401a8)': The method 'Worksheets' for the object 'Workbook' failed"
    Last edited by RoyMakaay1985; 06-17-2009 at 07:41 AM.

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    What if you replace Worksheets with just Sheets, as a matter of interest?

  17. #17
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    When I change it to sheets, the fault message again says 'Automation error'

    However i changed the source-code now, running the same line twice now, once for WB, then subsequently for WB2. The error message disappears. But, not all the data I want it to save, is saved... The first run (for WB) is not saved I assume, DaFeld (1, Zaehler) just returns empty cells.

    Please Login or Register  to view this content.

  18. #18
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    Your ReDim is destroying the data. Remove the second instance of:
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    Thanks! That helped. now I am just wondering what made the error appear in the first place... Could it be, that excel only allows to use one instance of a Workbook at a time?

  20. #20
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    re: problem Automation Error

    Nope, that shouldn't be an issue. Is there any code in those workbooks?

  21. #21
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    re: problem Automation Error

    No, they're just filled with Data

+ 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