+ Reply to Thread
Results 1 to 12 of 12

Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

  1. #1
    Registered User
    Join Date
    10-05-2017
    Location
    Milwaukee
    MS-Off Ver
    2016
    Posts
    15

    Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    The macro runs with a button assigned to "CloseMe". It used to run for my needs but doesn't anymore (as I tried using this code in another workbook without success). Now it saves, closes, waits 10sec to reopen, but then closes right away.

    Please Login or Register  to view this content.
    I need the code to save, close, wait 10sec to reopen, stay open for 10min (to collect real time data), and then repeat this process (until I interrupt it manually to stop). Thanks
    Last edited by AliGW; 01-20-2019 at 02:42 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    .
    Once you close a workbook, you won't be able to reopen the same workbook using a macro that is contained in that workbook.

    You can use workbook A to close and reopen workbook B. Workbook A will need to remain open at all times.


    If you are capturing real time data (I presume from an internet connection ?), why can't you simply leave the workbook open,
    using the same timer to run a macro that directs the download of that data ?

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    Please read the forum rules regarding code tags. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    10-05-2017
    Location
    Milwaukee
    MS-Off Ver
    2016
    Posts
    15

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    Ok. Thanks for the info. Your suggestion was my original intent however getting excel to re-calculate the RTD was tricky. The RTD always timed out after a few minutes. I looked everywhere for a recalculate macro but most of them didn't work. Do you have any examples of re-calculating RTD? Getting rid of the open/close would be nice.The only way it seems I could re-calculate or refresh the RTD was by closing/re-opening which is leading me down this path.

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    .
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-05-2017
    Location
    Milwaukee
    MS-Off Ver
    2016
    Posts
    15

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    Thanks for the info. Let me give you the full code so you get the whole idea of how its running. RecordData sub is assigned to a command button to record the RTD that is stored in the cells B4:L4 then it captures that data and logs it on the next sheet each minute. StopRecordingData sub is assigned to another button. Then finally the CloseMe sub is linked to the main issue of closing, saving, and re-opening I am having. Where would the code you have above fit in? Thanks for your time.

    Please Login or Register  to view this content.
    Last edited by mjac101; 01-20-2019 at 04:57 PM.

  7. #7
    Registered User
    Join Date
    10-05-2017
    Location
    Milwaukee
    MS-Off Ver
    2016
    Posts
    15

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    Quote Originally Posted by AliGW View Post
    Please read the forum rules regarding code tags. Thanks.
    Just figured out how to do it. Sorry for this issue.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    .
    Test this and see if it works correctly :

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-05-2017
    Location
    Milwaukee
    MS-Off Ver
    2016
    Posts
    15

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    Hopefully I am commenting correctly. But at the start of this sub I get a compile error: Ambiguous Name detected: RecordData

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    10-05-2017
    Location
    Milwaukee
    MS-Off Ver
    2016
    Posts
    15

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    Hi Logit. I ended up using this to bypass the auto open/close code need. So far it is working and I'll let it run overnight. Perhaps you can help with another post of mine related to the same code.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-05-2017
    Location
    Milwaukee
    MS-Off Ver
    2016
    Posts
    15

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    This code works fine when the data is presented from a range on row B4:L4 of my worksheet. It records it on the next sheet in 1min intervals. However I added more data on the original sheet for the macro to capture on rows B5:L5, B6:L6, etc. I revised the .Range("B4:L13") and that worked but I get a bunch of #N/A's. Any help? Thanks

    Please Login or Register  to view this content.

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Workbook, Save, Close, Re-Open (w/ TimeValue),Repeat

    Quote Originally Posted by mjac101 View Post
    Hopefully I am commenting correctly. But at the start of this sub I get a compile error: Ambiguous Name detected: RecordData

    Please Login or Register  to view this content.
    That type error means you have another macro with the same name. You need to change the name of one of the macros to something different, and also
    every instance of that macro name where ever it is located to the same changed name.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA to Save , close and Re-open the workbook again
    By Kamal Asharaf in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-10-2018, 05:08 AM
  2. Open workbook copy&paste, save and close Repeat
    By JPSIMMON in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2016, 12:29 PM
  3. [SOLVED] Macro to open Excel file, run other macros save, and close file & repeat.
    By Ronnet2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2015, 09:47 AM
  4. Open/Save/Close Workbook via command button
    By nathan0519 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2015, 11:24 PM
  5. [SOLVED] Macro to open/close/save workbook
    By JonathanB2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-14-2014, 10:51 AM
  6. How to open,save and close another workbook from the current workbook using macro?
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2012, 10:42 AM
  7. Save an open workbook, then open template workbook and close the saved workbook
    By ondvirg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2009, 10:20 PM

Tags for this Thread

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