+ Reply to Thread
Results 1 to 15 of 15

tough one for me: access open excel workbooks that are NOT saved anywhere, need help

  1. #1
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    hi guys,

    first, let me shortly describe the problem. i operate a pharmaceutical research robot. the robot works automatically, by nature, and he works over night. he outputs some data into excel workbooks. because he keeps opening new workbooks for each plate (what is physically analyzed) he process, it ends with 40 or so open workbooks, which are not saved anywhere, and are named Book1, Book2 etc (no .xlsx ending or so). I want to develop a script, that then saves each of these files to a specific folder and start a data analysis (the data analysis part is ready). so far it sounds easy, right?

    the problem i do have, i can't open access the open files with

    Workbooks("Book1").Activate

    does anybody an idea?

    thanks

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    if the workbooks are open you could try accessing them by index:

    application.workbooks(1).activate

    -edit-
    if you wanted to loop over them, something like

    Please Login or Register  to view this content.
    OR

    Please Login or Register  to view this content.
    Last edited by GeneralDisarray; 06-29-2012 at 01:56 PM. Reason: forgot a code tag
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    unfortunately, no, does not work
    the workbook does not react to any commands

    but thanks, this was quick!

  4. #4
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    Please Login or Register  to view this content.
    [/QUOTE]

    it gives an error for the "in" in "for wbk in application.workbook
    just red text, expects an = etc

  5. #5
    Registered User
    Join Date
    05-13-2010
    Location
    Kozhikode, Keral, India
    MS-Off Ver
    Microsoft Office home and student 2019
    Posts
    49

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    I think the code should read
    Please Login or Register  to view this content.
    Best Regards
    Chandrajit

  6. #6
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    Quote Originally Posted by Chandrajit View Post
    I think the code should read
    Please Login or Register  to view this content.

    syntax is ok now, but it does still not work. the macro start, seems to run through (i only have a cell offset in the script for testing purposes), but there is no reaction in the open files

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    Hello RobotGuy,

    Welxome to the Forum!

    Are these workbooks open in the same instance of Excel or in separate instances or do you know?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    Are the workbooks open in the same instance of Excel as the workbook with the code?
    Everyone who confuses correlation and causation ends up dead.

  9. #9
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    no, their not. the software is opening a new instance

  10. #10
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    Sorry, forgot the "For EACH" my bad.

  11. #11
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    i think every workbook is a new instance, not only the one with the code

  12. #12
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    thnks for the help btw, and greetings to your pharmacist wife (strictly platonic

  13. #13
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    still doesn't work, sorry

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

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    Maybe something like
    Please Login or Register  to view this content.
    this assumes all the other workbooks were created in instances started prior to the instance the code is running in.

  15. #15
    Registered User
    Join Date
    06-29-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: tough one for me: access open excel workbooks that are NOT saved anywhere, need help

    seems to work. i tried to emulate the conditions from work at home. will test at, otherwise i will reopen the thread

    thanks, you really are the guru!

+ 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