Question : Using SaveAs in excel 2007 vba

Hello,

I am wanting to use the SaveAs function in VBA. It should save with a specific file name with the current date. I have one that works, code posted below, but it only works with the current date (a problem when the file is being run after midnight). I have tried a few other ways (such as referencing a cell formatted with todays date minus four hours), but it only transcribes as a TRUE value. Sad days.

Is there a way to include in the macro the date minus four hours? Thanks!


Sub SaveToWeeklyFolder()
Dim TodaysDate
TodaysDate = Date$

'This will save the file into the weekly folder as Tally Sheet mmddyyyy.xlsm
    ChDir _
        "G:\TPO\Shared\GUESTSERVICES\Guest Relations\Desktop Tracking\Current Week"
    ActiveWorkbook.SaveAs Filename:= _
        "G:\TPO\Shared\GUESTSERVICES\Guest Relations\Desktop Tracking\Current Week\Tally Sheet " & TodaysDate & ".xlsm" _
        , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False


End Sub

Answer : Using SaveAs in excel 2007 vba

Sub SaveToWeeklyFolder()

'This will save the file into the weekly folder as Tally Sheet mmddyyyy.xlsm
   ChDir _
       "G:\TPO\Shared\GUESTSERVICES\Guest Relations\Desktop Tracking\Current Week"
   ActiveWorkbook.SaveAs Filename:= _
       "G:\TPO\Shared\GUESTSERVICES\Guest Relations\Desktop Tracking\Current Week\Tally Sheet " & Format(Date - .17, "mmddyyyy") & ".xlsm" _
       , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False


End Sub

Kevin
Random Solutions  
 
programming4us programming4us