+ Reply to Thread
Results 1 to 5 of 5

AutoSave

  1. #1
    Registered User
    Join Date
    11-10-2017
    Location
    Armenia
    MS-Off Ver
    2010 + 2013
    Posts
    15

    Question AutoSave

    can someone fix this for me please: keep getting rutime error 1004 Application.OnTime

    **in the ThisWorkbook section

    Option Explicit
    Private Sub Workbook_Open()
    macro1
    End Sub

    **in a module
    Option Explicit

    Sub macro1()
    Application.OnTime Now + TimeValue("00:00:01"), "sveIt" '<-- this tells the macro, in 5 seconds run yourself again. 'place your other code here

    End Sub

    Sub sveIt()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Dim dt As String

    dt = Format(Now(), "mm-dd-yyyy hh.mm.ss")
    ThisWorkbook.SaveAs Filename:="\\MY DIRECTORY\dt.xlsm"

    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    macro1
    End Sub

  2. #2
    Registered User
    Join Date
    06-03-2015
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    64

    Re: AutoSave

    I see a few things.

    You need to specify the exact location and the file format.
    You can only add "Option Explicit" to the very top of a module. If you need to add it to another sub, then you will have to create a new module.
    And finally, your time is set to 1 second not 5.

    Here is a working version of your code. Make sure to change the path.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-10-2017
    Location
    Armenia
    MS-Off Ver
    2010 + 2013
    Posts
    15

    Re: AutoSave

    Quote Originally Posted by jonathann3891 View Post
    I see a few things.

    You need to specify the exact location and the file format.
    You can only add "Option Explicit" to the very top of a module. If you need to add it to another sub, then you will have to create a new module.
    And finally, your time is set to 1 second not 5.

    Here is a working version of your code. Make sure to change the path.

    Please Login or Register  to view this content.
    so all this code should write in module or thisworkbook ? i have mentioned there part in thisworkbook and the second part in the module

  4. #4
    Registered User
    Join Date
    06-03-2015
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    64

    Re: AutoSave

    I didn't see where you said they were separated, I apologize.

    You can have them separated as you originally stated. You can also add the option explicit back from where I removed it.

  5. #5
    Registered User
    Join Date
    11-10-2017
    Location
    Armenia
    MS-Off Ver
    2010 + 2013
    Posts
    15

    Re: AutoSave

    jonathann3891 thank you so so much works like a charm

+ 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. Autosave
    By Rokuro kubi in forum Excel General
    Replies: 7
    Last Post: 04-15-2006, 10:20 AM
  2. AutoSave
    By Brent in forum Excel General
    Replies: 3
    Last Post: 02-15-2006, 02:35 PM
  3. [SOLVED] Autosave VBA
    By Paulymon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2005, 09:30 AM
  4. Opened Autosave but when closing workbook Autosave closes itself
    By Ken in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-29-2005, 01:05 PM
  5. Autosave
    By rashid munawar in forum Excel General
    Replies: 1
    Last Post: 09-07-2005, 03:05 PM
  6. [SOLVED] AutoSave
    By Tee in forum Excel General
    Replies: 4
    Last Post: 08-11-2005, 08:05 AM
  7. Autosave???
    By opiate in forum Excel General
    Replies: 4
    Last Post: 01-21-2005, 10:01 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