+ Reply to Thread
Results 1 to 6 of 6

Autosave by timer

Hybrid View

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

    Autosave by timer

    Hello,
    can someone give me a solution,

    i have an excel file and i want a VBA code for autuosave by timer and in specific location.

    so when i open the excel file the code should run automatically and count 30 second then save it in specific location.


    Thanks in advance.

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

    Re: Autosave by timer

    .
    Option Explicit
    
    Sub macro1()
         Application.OnTime Now + TimeValue("00:00:30"), "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 FName           As String
        Dim FPath           As String
        Dim dt              As String
        
        dt = Format(Now(), "mm-dd-yyyy hh.mm.ss")
        FPath = "C:\Users\My\Desktop"       ''<-- Change SAVE DIRECTORY as required
        FName = Sheets("Sheet1").Range("A1").Text & "-" & dt & ".xlsm"
        ThisWorkbook.SaveAs Filename:=FPath & "\" & FName
        
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
    macro1
    End Sub
    Attached Files Attached Files

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

    Re: Autosave by timer

    Dear Logit, thank you for your help, the code working as well, but is there an option to run the code without clicking on the button ? like the code start automatically when i open the file.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Autosave by timer

    You can call the procedure "Macro1" in thisworkbook module in that way
    Private Sub Workbook_Open()
        Macro1
    End Sub
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

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

    Re: Autosave by timer

    YasserKhalil, can you please edit it in the file that Logit send it, im not good in the coding so i dont have an indea where to write your code.

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Autosave by timer

    Here's the file
    Attached Files Attached Files

+ 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. timer for 30 minutes and timer based events
    By mohak12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-11-2014, 06:20 PM
  2. Replies: 1
    Last Post: 12-12-2012, 08:46 PM
  3. Replies: 1
    Last Post: 03-10-2006, 08:10 AM
  4. [SOLVED] 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:: off
    By PaulOakley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2005, 09:05 AM
  6. 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