+ Reply to Thread
Results 1 to 3 of 3

Code preventing Excel from closing down

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    4

    Code preventing Excel from closing down

    At the onset, I am not proficient with VBA coding and trying my hands on it for the first time.

    I created a message board in the excel tool that I am building that displayes three messages. It is a List box for which the Captin keeps changing every 5 seconds.

    This is (I believe) preventing the excel file from closing. When I close, I get the Save / Dont save option. Irrespective of what I press, the file closes and then opens up again.

    When I turn both of these codes off, it closes properly.

    I am giving the code below:

    Under Module 1:
    Public Sub Scroll()
    Dim temp As Variant
    temp = Sheet20.Label1.Caption
    Sheet20.Label1.Caption = Sheet20.Label2.Caption
    Sheet20.Label2.Caption = Sheet20.Label3.Caption
    Sheet20.Label3.Caption = temp
    Application.OnTime Now + TimeValue("00:00:05"), "ScrollIt"
    End Sub
    Under 'This Workbook' :

    Public Sub Workbook_Open()
            
            Application.OnTime Now + TimeValue("00:00:05"), "Scroll"
            
    End Sub

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Code preventing Excel from closing down

    You need to include code to "turn off" OnTime before you exit Excel. See:

    http://www.cpearson.com/Excel/OnTime.aspx
    Gary's Student

  3. #3
    Registered User
    Join Date
    09-18-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Code preventing Excel from closing down

    Thanks a bunch. This was very helpful. I changed the codes as necessary and it works perfectly now.

+ 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