+ Reply to Thread
Results 1 to 7 of 7

" Save as" a workbook automatically on daily basis

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    " Save as" a workbook automatically on daily basis

    Folks,
    Is there any way (VBA) to save as a workbook automatically on daily basis in a particular folder? The file name should be with current date. Thanks in advance for your expertise.
    *
    Joshi
    Last edited by krjoshi; 03-18-2012 at 10:43 AM.

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: " Save as" a workbook automatically on daily basis

    You can schedule Excel through using Windows Task schedular - you will need to be a little more specific - where is the workbook that is going to be saved and what is the workbook name/type - could you be a little more specific giving details of what workbook needs to be saved and how you want the filename to be e.g.filenameddmmyy.xlsx
    This certainly can be done however if you could be a little more specific about the file to save and where it is to be saved to it would make things a lot easier. All you would need to do is place all the code inside macro enabled workbook in the workbook_open event and then schedule that workbook to be opened by Windows task scheduler at a certain time each day. If you could just explain in a little more detail then some code can be written for you.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: " Save as" a workbook automatically on daily basis

    Hi Smuzoen,

    I have a workbook "Master JobList" saved in a share drive "M:\05-Shutdown and Turnarounds (ST)\05-12-AKG2\2013\02 - Joblist\04 - Updated Joblist", what I am looking for, the same file should save as automatically on daily basis to another folder "M:\05-Shutdown and Turnarounds (ST)\05-12-AKG2\2013\02 - Joblist\04 - Updated Joblist\backup". And, the file name like "Master JobList_11-Mar-12" based on the current date. Can you please help me?

    Thanks in advance.

    Joshi

  4. #4
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: " Save as" a workbook automatically on daily basis

    Folks,

    Please help me.

    Thanks,
    Joshi

  5. #5
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: " Save as" a workbook automatically on daily basis

    Try this VBScript file - paste the following code into Notepad and save as Backup.vbs. Test it by double-clicking Backup.vbs, wherever you saved it. If it works, create a scheduled task to run this script daily.
    Dim FSO, FormattedDate
    
    FormattedDate = Right("0" & Day(Date),2) & "-" & MonthName(Month(Date),True) & "-" & Right(Year(Date),2)
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    
    FSO.CopyFile "M:\05-Shutdown and Turnarounds (ST)\05-12-AKG2\2013\02 - Joblist\04 - Updated Joblist\Master JobList.xls", _
    	"M:\05-Shutdown and Turnarounds (ST)\05-12-AKG2\2013\02 - Joblist\04 - Updated Joblist\backup\Master JobList_" & FormattedDate & ".xls"
    Note - I've assumed your workbook has the file extension .xls. Change this in the code if I'm wrong.

  6. #6
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: " Save as" a workbook automatically on daily basis

    Copy this code into a workbook - you can name it anything e.g. backupWorkbook.xlsm
    Private Sub Workbook_Open()
    Dim oldPath As String, newPath As String
    oldPath = "M:\05-Shutdown and Turnarounds (ST)\05-12-AKG2\2013\02 - Joblist\04 - Updated Joblist" 'Folder file is located in
    newPath = "M:\05-Shutdown and Turnarounds (ST)\05-12-AKG2\2013\02 - Joblist\04 - Updated Joblist\backup" 'Folder to copy file to
    Set fs = CreateObject("Scripting.FileSystemObject")
    Application.DisplayAlerts = False
    fs.CopyFile oldPath & "\" & "Master JobList.xls", newPath & "\" & "Master JobList" & Format(Now, "ddMMMyy") & ".xls" 'This file was an .xls file
    Set fs = Nothing
    ActiveWorkbook.Close False
    Application.DisplayAlerts = True
    End Sub
    In Task scheduler just add this workbook as a scheduled task to run at some time during the day

  7. #7
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: " Save as" a workbook automatically on daily basis

    Hi Guys,

    Thanks a lot. Both options are working great.

    Thanks,
    Joshi

+ 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