![]() |
|
#1
|
|||
|
|||
![]() ![]() I set the code below to publish pdf: Sub MakePDF() DirOpenFile = ActiveDocument.FilePath Directory = Dir$(DirOpenFile) Do While Len(Directory) <> 0 Set File = OpenDocument(Directory) NameWithoutCdr = Replace(Directory, ".cdr", ".pdf") File.PublishToPDF (DirOpenFile & NameWithoutCdr) File.Close Counting = Counting + 1 Directory = Dir$ Loop End Sub Could anyone tell me what should I do to make the macro search also into existing subfolders (if they exist or not)? |
#2
|
||||
|
||||
![]()
You can find Alex's original code here: Finding a File in Sub Folders I have combined the changes in the thread to the following code:
Code:
Private Sub EnumSubFolders(ByVal SrcFolder As String, ByVal Folders As Collection) Dim f As String f = Dir(SrcFolder & "\*.*", vbDirectory) While f <> "" If f <> "." And f <> ".." And (GetAttr(SrcFolder & "\" & f) And vbDirectory) <> 0 Then Folders.add SrcFolder & "\" & f End If f = Dir() Wend End Sub Private Sub ProcessFolder(ByVal SrcFolder As String) Dim f As String, sFolder As Variant Dim Folders As New Collection Dim n As Long ' Create a list of folders and subfolders EnumSubFolders SrcFolder, Folders n = 1 While n <= Folders.Count EnumSubFolders Folders(n), Folders n = n + 1 Wend ' Process the CDR files in each of the folders found For Each sFolder In Folders f = Dir(sFolder & "\*.cdr") While f <> "" ProcessFile sFolder & "\" & f f = Dir() Wend Next sFolder End Sub Private Sub ProcessFile(ByVal sFile As String) ' Do your file processing here End Sub Code:
Public Sub Test() ProcessFolder "D:\Temp" End Sub -Shelby |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
folders in International Languages | jemmyell | CorelDRAW/Corel DESIGNER VBA | 2 | 03-02-2009 17:01 |
Checking fill type | knowbodynow | CorelDRAW/Corel DESIGNER VBA | 2 | 08-03-2006 02:18 |
Checking for shape intersection | Todor | CorelDRAW/Corel DESIGNER VBA | 3 | 03-07-2005 10:48 |
Finding a File in Sub Folders | shelbym | CorelDRAW/Corel DESIGNER VBA | 10 | 10-05-2004 08:02 |
Checking if a file exists before importing | Rick Randall | CorelDRAW/Corel DESIGNER VBA | 1 | 01-03-2004 10:33 |