#1
|
|||
|
|||
Looping in Correct order
Greeting to all, Below is my code for looping through files in a folder but where I face the problem is it jumps from 01 to 10, 11, 12, and so on. What should be done on following code so that it loops sequentially?
Code:
Sub loopfo() Dim fso As FileSystemObject Dim fld As FileDialog,strname As String,fp As String,fdr As Scripting.folder,f As Scripting.file Dim doc As Document On Error Resume Next Set fld = Application.FileDialog(msoFileDialogFolderPicker) With fld .Show .AllowMultiSelect = False .Title = "Select the Desired Folder" End With fp = fld.SelectedItems(1) Set fso = New Scripting.FileSystemObject Set fdr = fso.GetFolder(fp) For Each f In fdr.Files If Left(fso.GetExtensionName(f.Path), 3) = "doc" Then ' And Left(f.Name, 2) = "0" Set doc = Documents.Open(f.Path) doc.Close (True) End If Next End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Combobox Looping | blaisjoel | Word VBA | 1 | 04-17-2019 05:50 AM |
How do I paste items in the order they were copied, not the order the are listed? | manish500 | Word | 6 | 07-25-2018 12:07 AM |
Looping several slides | gabby | PowerPoint | 11 | 04-25-2015 03:05 AM |
Need help on macro for looping | kilosub | Word VBA | 31 | 07-27-2011 01:37 PM |
Looping video | tomasball | PowerPoint | 0 | 10-30-2010 02:38 PM |