Hello
I suppose this code will create folders current year and month and save file as pdf inside month based on current month , but suddenly shows error message can't open this file !
so what's the problem?
I suppose this code will create folders current year and month and save file as pdf inside month based on current month , but suddenly shows error message can't open this file !
VBA Code:
Sub DateFolderSave()
Application.DisplayAlerts = False
' Check for year folder and create if needed
If Len(Dir("c:\" & Year(Date), vbDirectory)) = 0 Then
MkDir "c:\" & Year(Date)
End If
' Check for month folder and create if needed
If Len(Dir("c:\" & Year(Date) & "\" & MonthName(Month(Date), False), vbDirectory)) = 0 Then
MkDir "c:\" & Year(Date) & "\" & MonthName(Month(Date), False)
End If
' Save File
ActiveSheet.SaveAs Filename:= _
"c:\" & Year(Date) & "\" & MonthName(Month(Date), False) & "\" & Format(Date, "mm.dd.yy") & ".PDF" _
, CreateBackup:=False
Application.DisplayAlerts = True
' Popup Message
MsgBox "File Saved As:" & vbNewLine & "c:\" & Year(Date) & _
"\" & MonthName(Month(Date), False) & "\" & Format(Date, "mm.dd.yy") & ".PDF"
End Sub