2
Guys I made this macro to create folders and subfolders automatically, but I need to save the file I’m editing inside the created folder... someone can help me?
Follows the script
' MACRO PARA CRIAR PASTA DE ANO/MES/DIA
Public Const sCaminho = ""
Dim Pasta As New FileSystemObject
Public Function fnccriardiretorio(data As Date)
If Pasta.FolderExists(sCaminho & "\" & Format(data, "yyyy")) Then
fncmes (data)
Else
Pasta.CreateFolder (sCaminho & "\" & Format(data, "yyyy"))
fncmes (data)
End If
End Function
Public Function fncmes(data As Date)
If Pasta.FolderExists(sCaminho & "\" & Format(data, "yyyy") & _
"\" & Format(data, "mmmm")) Then
Call fncdia(data)
Else
Pasta.CreateFolder (sCaminho & "\" & Format(data, "yyyy") & _
"\" & Format(data, "mmmm"))
Call fncdia(data)
End If
End Function
Public Function fncdia(data As Date)
If Pasta.FolderExists(sCaminho & "\" & Format(data, "yyyy") & _
"\" & Format(data, "mmmm") & "\" & Format(data, "dd")) Then
Else
Pasta.CreateFolder (sCaminho & "\" & Format(data, "yyyy") & _
"\" & Format(data, "mmmm")) & "\" & Format(data, "dd")
End If
End Function
Sub chamafuncao()
Dim data As Date
data = InputBox("Entre com a Data _EX DD/MM/AAAA")
Call fnccriardiretorio(data)
End Sub
To save a workbook object, use the method Saveas and a Document, the method Saveas2
– danieltakeshi