+ Reply to Thread
Results 1 to 3 of 3

Restart macro when "another" workbook is opened

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,287

    Restart macro when "another" workbook is opened

    Due to the instability of 2007, and a habit some people have of leaving complex files open for days on end without saving, I had decided on automatically shutting them if workbook not used for 30 minutes, leaving them back at the main menu used to open the workbooks. This works well and requires no interaction from the user even though a warning pop up is given. How can I get the macro to restart after it has run because when the menu is used to re-open files after the event has occurred the macro does not restart.

    In workbook
    Please Login or Register  to view this content.
    In module
    Please Login or Register  to view this content.
    any pointers appreciated

    requires widows script host object model to be run in "tools" - "references" of vba in menu workbook
    Last edited by nigelog; 08-01-2013 at 11:01 AM.

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,287

    Re: Restart macro when "another" workbook is opened

    Please Login or Register  to view this content.
    I tried adding " Call SetTime" after the Next WB in the second last line of code above. This does reset the timer but this time the pop up message does not automatically disappear and requires the user to click on the box to close the file which defeats the purpose

    Could I "close and reopen" the menu workbook that contains the above code, and what would that involve

    Ta Nigel

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,287

    Re: Restart macro when "another" workbook is opened

    Sorted

    When other workbooks are automatically closed the workbook that is the main menu is closed and reopened and "SetTime" called. This was the workaround for after the first "close workbooks", as the SetTime did not automatically restart, and clicking a macro button on the menu did not constitute a "SheetSelectionChange". If after the first close a workbook was opened from a macro button, there was no more timed "closed if inactive".

    This way it continues in a loop until the "menu" workbook is closed.

    In Workbook
    Please Login or Register  to view this content.
    In module
    Please Login or Register  to view this content.
    A counter was added to cell j6 to make sure workbook was opening and closing and can be hidden to monitor how many times the macro was invoked in use

    Ta Nigel

+ 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. [SOLVED] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. How can i copy value from "HTMLText"(EMBED("Forms.HTML:Text","")),using Macro
    By andrewyang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2010, 12:47 AM
  3. Replies: 0
    Last Post: 01-04-2006, 06:55 PM
  4. [SOLVED] Call a sub statement in "Personal Macro Workbook" from "ThisWorkbo
    By QC Coug in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2005, 03:05 PM
  5. Macro working in "This Workbook", but not while in "Personal.xls"
    By markx in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-07-2005, 01:06 PM

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