How to create folder in desktop with vba whenever the excel book is opened, if exist, ignore.
Message if create new folder, silent if the folder exist.
I have the code to create folder on desktop
Message if create new folder, silent if the folder exist.
I have the code to create folder on desktop
Sub CriarPastaFaturaDesktop()
'Variable declaration
Dim sFolderName As String
Dim sDesktopPath As String, sFolderPath As String
'Find Desktop path location
sDesktopPath = Environ("USERPROFILE") & "\Desktop\"
'Define folder name to create on the desktop
sFolderName = "FATURAS"
'Folder Path
sFolderPath = sDesktopPath & sFolderName
'Create FSO Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
'Check Specified Folder exists or not
If oFSO.FolderExists(sFolderPath) Then
'If folder is available on the desktop
MsgBox "Uma pasta com o mesmo nome já existe no Desktop!", vbInformation, "INFO"
Exit Sub
Else
'Create Folder
MkDir sFolderPath
'Diplay messafe on the screen
MsgBox "Pasta criada com sucesso em: " & vbCrLf & vbCrLf & sFolderPath, vbInformation, "INFO"
End If
End Sub