+ Reply to Thread
Results 1 to 4 of 4

My workbook keeps opening by itself!

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    Cranfield
    MS-Off Ver
    Excel 2007
    Posts
    68

    My workbook keeps opening by itself!

    Hi all,

    I have just added some code to make my workbook close after it has been inactive for 5 minutes...this works fine except it opens itself up again after 5 minutes.
    If I select 'Enable Macros' it closes immediately and if not, it will stay open.

    Here is all of the code I put in for the auto shut down:
    ThisWorkbook:
    Please Login or Register  to view this content.
    Module1:
    Please Login or Register  to view this content.
    Any ideas what is going on?

  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
    7,014

    Re: My workbook keeps opening by itself!

    It has to do with "Application.OnTime". That command starts the Windows timer so your macro knows when the five minutes has been reached. What is needed is to stop the timer with syntax resembling ...

    "Application.OnTime EarliestTime:=Now + TimeValue("00:05:00"), Procedure:=AutoSave, Schedule:=False"
    The "Schedule:=False" being the key.

    However, I am experiencing the same issue with my workbook and have been unable to get the above to actually work. A search of the Forum here will realize most folks are using : See http://www.cpearson.com/excel/ontime.aspx for understanding how to stop the timer. Except I am one of those folks who can't wrap my mind around the syntax to get it working in on my workbook.

    If you manage to get your project to function as desired, please give my post a go :
    http://www.excelforum.com/excel-prog...e-display.html

    Thanks !

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: My workbook keeps opening by itself!

    James

    You seem to be using OnTime quite a lot in that code.

    The only thing you don't do is disable it when you close the workbook.

    Doing that should stop the workbook re-opening.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    04-30-2013
    Location
    Cranfield
    MS-Off Ver
    Excel 2007
    Posts
    68

    Re: My workbook keeps opening by itself!

    Thanks for your advice.

    I added this macro to stop it opening and closing...seems to work so far!
    Please Login or Register  to view this content.

+ 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