title: Run VBA code on specific time
body: <p>I found the following code on this web site "save Excel file as CSV" is there any way with help of you'll I can auto run this code on specific time (11:00 pm every night), and save file name as current date (hr2015-05-05), any help will be greatly appreciated. Thanks</p>
  
  <pre><code>Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
  Dim Sourcewb As Workbook
  Dim Destwb As Workbook
  Dim TempFileName As String
  
  With Application
      .ScreenUpdating = False
      .EnableEvents = False
      .DisplayAlerts = False
  End With
  
  Set Sourcewb = ActiveWorkbook
  TempFileName = Sourcewb.FullName + ".csv"
  
  'Copy the sheet to a new workbook
  ActiveSheet.Copy
  Set Destwb = ActiveWorkbook
  
  'Save the new workbook and close it
  With Destwb
      .SaveAs Filename:=TempFileName, FileFormat:=xlCSV, ConflictResolution:=xlLocalSessionChanges
      .Close SaveChanges:=False
  End With
  
  With Application
      .ScreenUpdating = True
      .EnableEvents = True
      .DisplayAlerts = True
  End With
  End Sub
  </code></pre>
  
  <p>Edit fixed tag issue</p>