+ Reply to Thread
Results 1 to 2 of 2

New to Excel Forum. Working on timed autosave worksheets.

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Amarillo, Texas
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    2

    New to Excel Forum. Working on timed autosave worksheets.

    Found a nice post about exactly what to do but when I save the workbook, I get compiler error.

    I placed this in the Workbook section:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    and this in the General:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    When I save the workbook, I get a highlight on StartTimer in the Private Sub Workbook_Open() and it says Compile error:
    Sub or Function not defined

    Any help would be appreciated.

    Wayne
    Last edited by arlu1201; 07-09-2013 at 01:41 AM. Reason: Use code tags in future.

  2. #2
    Registered User
    Join Date
    06-19-2013
    Location
    Amarillo, Texas
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    2

    Re: New to Excel Forum. Working on timed autosave worksheets.

    OK, found the solution to help those of you who are having the same problem or will have this problem.

    I merged everything into the Workbook General section.

    in the line "Application.OnTime RunTime, "SaveBook", schedule:=False"

    Add the qualifier ThisWorkbook to "SaveBook" so it will read

    Application.OnTime RunTime, "ThisWorkBook.SaveBook", schedule:=False

    This WILL fix that problem.

    So the final product will be:

    Option Explicit
    Public RunTime
    Private Sub Workbook_Open()
    StartTimer
    End Sub
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    StopTimer
    End Sub
    Sub StartTimer()
    RunTime = Now + #12:05:00 AM#
    Application.OnTime RunTime, "ThisWorkBook.SaveBook", schedule:=True
    End Sub
    Sub SaveBook()
    ActiveWorkbook.Save
    StartTimer
    End Sub
    Sub StopTimer()
    On Error Resume Next
    Application.OnTime RunTime, "ThisWorkBook.SaveBook", schedule:=False
    End Sub


+ 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