PDA

View Full Version : Macro to save a readonly copy of file with todays date



Nilz
11-11-2014, 03:28 AM
Hey guys,

Having a little trouble with this; I just want to save a read-only copy of a file in a different folder with todays date but for some reason I cant figure out whats wrong with this code, it saves the file name with "dt" and not the actual date? (help would be really appreciated!)


Sub Readonly()
' SaveAsReadOnly Macro
Dim dt As String
dt = Format(Now, "yyyymmdd")
ChDir "G:\Capital Markets\Tools\DS"
ActiveWorkbook.SaveCopyAs Filename:= _
"G:\Capital Markets\Tools\DS\Spreads & dt.xlsb"
SetAttr "G:\Capital Markets\Tools\DS\Spreads & dt.xlsb", vbReadOnly
End Sub

westconn1
11-11-2014, 01:24 PM
try
ActiveWorkbook.SaveCopyAs Filename:= _
"G:\Capital Markets\Tools\DS\Spreads" & dt & ".xlsb"

Nilz
11-12-2014, 06:39 AM
Awesome that did it! Thanks a bunch :)