I'm using CorelDraw 2018 and each time I create a Drawing I save the drawing into a Job Folder named after the Filename. Manually I then create 3 Folders within this Job Folder, was wanting to create a Macro so I could Save the Filename to the Job Folder and then press a Function Key to create the other 3 Folders automatically.
An Example would be like shown with the "<Job Folder>" being the folder name the Cdr file is saved in.
C:\<Job Folder Name>/Files
C:\<Job Folder Name>/Files/Focus/
C:\<Job Folder Name>/Files/SinoColor
Hoping someone can help me out with this. Thanks in Advance
You could try this VBA code:
Sub create_folders_01() Dim FSO As New FileSystemObject Dim strBaseFilePath As String Const strSubFolder1Name = "" If Not ActiveDocument Is Nothing Then strBaseFilePath = ActiveDocument.FilePath If Not strBaseFilePath = "" Then If Not FSO.FolderExists(strBaseFilePath & "Files") Then FSO.CreateFolder (strBaseFilePath & "Files") Else MsgBox "The folder" & vbcrlf & vbcrlf & """" & strBaseFilePath & """" & vbcrlf & vbcrlf & "already exists." End If If Not FSO.FolderExists(strBaseFilePath & "Files\Focus") Then FSO.CreateFolder (strBaseFilePath & "Files\Focus") Else MsgBox "The folder" & vbcrlf & vbcrlf & """" & strBaseFilePath & "Files\Focus\" & """" & vbcrlf & vbcrlf & "already exists." End If If Not FSO.FolderExists(strBaseFilePath & "Files\SinoColor") Then FSO.CreateFolder (strBaseFilePath & "Files\SinoColor") Else MsgBox "The folder" & vbcrlf & vbcrlf & """" & strBaseFilePath & "Files\SinoColor\" & """" & vbcrlf & vbcrlf & "already exists." End If Else MsgBox "No file path is available for the active document." & vbcrlf & vbcrlf & "Document must be saved in order to have a file path." End If Else MsgBox "No document is active." End If End Sub
Many Thanks for that Eskimo ... when adding it and trying to run I'm getting the attached Error
You are welcome.
Thanks Eskimo and Mek for helping me out, very much appreciated!!!!!
Eskimo or Mek, can one of you give me the added lines to create a textfile within the strBaseFilePath & "Files" folder please, nothing needs to be in the textfile, just the filename of "Details"
THANK YOU
You could try this:
Sub create_folders_01() Dim FSO As New FileSystemObject Dim strBaseFilePath As String Const strSubFolder1Name = "" If Not ActiveDocument Is Nothing Then strBaseFilePath = ActiveDocument.FilePath If Not strBaseFilePath = "" Then If Not FSO.FolderExists(strBaseFilePath & "Files") Then FSO.CreateFolder (strBaseFilePath & "Files") Else MsgBox "The folder" & vbcrlf & vbcrlf & """" & strBaseFilePath & """" & vbcrlf & vbcrlf & "already exists." End If If Not FSO.FolderExists(strBaseFilePath & "Files\Focus") Then FSO.CreateFolder (strBaseFilePath & "Files\Focus") Else MsgBox "The folder" & vbcrlf & vbcrlf & """" & strBaseFilePath & "Files\Focus\" & """" & vbcrlf & vbcrlf & "already exists." End If If Not FSO.FolderExists(strBaseFilePath & "Files\SinoColor") Then FSO.CreateFolder (strBaseFilePath & "Files\SinoColor") Else MsgBox "The folder" & vbcrlf & vbcrlf & """" & strBaseFilePath & "Files\SinoColor\" & """" & vbcrlf & vbcrlf & "already exists." End If If Not FSO.FileExists(strBaseFilePath & "Files\Details.txt") Then FSO.CreateTextFile (strBaseFilePath & "Files\Details.txt") Else MsgBox "The file" & vbcrlf & vbcrlf & """" & strBaseFilePath & "Files\Details.txt" & """" & vbcrlf & vbcrlf & "already exists." End If Else MsgBox "No file path is available for the active document." & vbcrlf & vbcrlf & "Document must be saved in order to have a file path." End If Else MsgBox "No document is active." End If End Sub
PERFECT ... Thanks Eskimo, have a Fantastic Weekend