Hi all
I have been using this VBA for a few months now to create a new folder (if needed) and save my new file however today it's saving the document as "file" and not an Excel file. I have tried to tweak the FileFormat but to no avail. Can anyone help please?
thanks
Dim strGenericFilePath As String: strGenericFilePath = "HIDDEN FOR PRIVACY"
Dim strYear As String: strYear = Year(Date) & "\"
Dim strMonth As String: strMonth = Format(Date, "mm.Mmmm") & "\"
DateStamp = Format(Date, "yy.mm.dd")
Dim strFileName As String: strFileName = (DateStamp & " - " & Range("A4").Value & " - " & ws.Name)
' Check for year folder and create if needed
If Len(Dir(strGenericFilePath & strYear, vbDirectory)) = 0 Then
MkDir strGenericFilePath & strYear
End If
' Check for month folder and create if needed
If Len(Dir(strGenericFilePath & strYear & strMonth, vbDirectory)) = 0 Then
MkDir strGenericFilePath & strYear & strMonth
End If
' Save File
ActiveWorkbook.SaveAs Filename:= _
strGenericFilePath & strYear & strMonth & strDay & strFileName, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=True
I have been using this VBA for a few months now to create a new folder (if needed) and save my new file however today it's saving the document as "file" and not an Excel file. I have tried to tweak the FileFormat but to no avail. Can anyone help please?
thanks
Dim strGenericFilePath As String: strGenericFilePath = "HIDDEN FOR PRIVACY"
Dim strYear As String: strYear = Year(Date) & "\"
Dim strMonth As String: strMonth = Format(Date, "mm.Mmmm") & "\"
DateStamp = Format(Date, "yy.mm.dd")
Dim strFileName As String: strFileName = (DateStamp & " - " & Range("A4").Value & " - " & ws.Name)
' Check for year folder and create if needed
If Len(Dir(strGenericFilePath & strYear, vbDirectory)) = 0 Then
MkDir strGenericFilePath & strYear
End If
' Check for month folder and create if needed
If Len(Dir(strGenericFilePath & strYear & strMonth, vbDirectory)) = 0 Then
MkDir strGenericFilePath & strYear & strMonth
End If
' Save File
ActiveWorkbook.SaveAs Filename:= _
strGenericFilePath & strYear & strMonth & strDay & strFileName, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=True