Description (2017.3.26):
1. not finished, writes the new folder, and the next new word, rename, find coaching, the coaching copied into it, because it will give coaching number should be a lot of trouble
Public Sub test1. 1 () 2 Dim path . 3 Dim filename . 4 Dim Folders (the To 100. 1) . 5% Dim I, J% . 6 = I. 1 . 7. 1 J = . 8 '1. get all the folders to 9 path = ThisWorkbook. & path "\ oriFolder \" 10 folders (. 1) = path . 11 'here and in the following classes folders array array 100 is provided only in length, for the convenience of debugging, or sometimes a large number of blank lines, can be increased in practice . 12 'dir second called with no arguments, returns to the same folder under the second file! ! 13 'filename = Dir (folders ( i), vbDirectory) where filename is acquired first file in the folders (1) path to the folder. "" 14' first folder to find the dir. "", Then i = 1, enters a do loop, the oriFolder this layer folders dir out (101 and 102), 15 'to find a folder put j by 1 (the last j = 3), the folders (i) is modified. "" path , 101 and 102 route path, inside the loop will do until do such a thing 16 'do an until then done, I add to the 1, 2 becomes, when the filename = dir (folders (i) , vbDirectory), folders (2) is to do until the cycle has been modified in a path 101, 17 'continue to do until loop, j = 3 at present, and then began to increase, the purpose is to make folders (j) to continue in the future to increase the array of elements, such as the 101 after all the folders in the path of the path added to it, 18' i becomes 3, then 102 start traversing folder 19 'if there is also folders 101, 101 and 102 on the other to traverse are completed, because each increase of only 1 i, and j as long as there is a folder is incremented, 20' so long as the i j is not the number, it will have been traversed go down and take out all the subfolders traverse 21 the Do the While i <= j 22 filename = Dir (Folders (i), vbDirectory) 'filename = "." 23 the Do the Until filename = "" 24 the if the InStr (filename, ".") = 0 the Then 25 J = J +. 1 26 is' when i = 1, when the folders (j) 1,2,3 are ",", the directory 101 27 folders (j) = folders (i ) &filename & "\" 28 End If The Dir filename = 29 53 Loop 30 Loop 31 i = i + 1 32 Loop 33 is 'P = the For the To the UBound. 1 (Folders) 34 is' the If Folders (P) <> "" the Then 35 'the Debug.Print (Folders (P)) 36' End the If 37 [ 'the Next 38 is' 2. From each folder Get all courses in, into an array 39 Dim classes (the To 100. 1) 40 Dim class 41 is Dim P 42 is Dim Q 43 is P =. 1 44 is Q =. 1 45 46 is the To the UBound the For P =. 1 (Folders) 47 Folders the If (P ) <> "" the Then 48 the Dir = class (Folders (P) & "*. *") 49 the Until the Do class = "" 50 classes (Q) = Folders (P) &class 51 q = q + 1 52 class = Dir 54 End If 55 Next 56 57 58 '3. In desFolder in the new folder, generating coaching RTF 59 Dim path2 60' to the first set of canonical correlation AS Dim 61 is of As the RegExp Dim REG 62 is the MatchCollection Dim myMatches of As 63 is Dim myMatch match of As 64 Dim Books (the to 10. 1) 65 Dim bnum 66 m Dim 67 Dim n- 68. 1 = n- 69. 1 m = 70. 1 bnum = 71 is' word of the set of operating again AS Dim 72 Dim wordApp the Word.Application of As 73 is the set wordApp = New Word the .application 74 path2 = ThisWorkbook.path & "\ desFolder \" 75 the Set New RegExp REG = 76 'get all versions of the folder name 77 filename2 = Dir (path, vbDirectory) 78 the Do the Until filename2 = "" 79 the If the InStr (filename2, ".") = 0 the Then 80 Books (bnum) = filename2 81 bnum = bnum +. 1 82 End the If 83 filename2 = the Dir 84 Loop 85 'generates a version of the folder desFolder inside 86 For m = 1 To the UBound (Books) 87 'Books (m) is not empty, and the folder does not exist, a new folder 88 If books (m) <> "" and Dir (path2 & books (m), vbDirectory) = "" Then the MkDir 89 (path2 & Books (m)) 90 'new word, named "01_" stars "_DianBo.doc" 91 is' open each class, find coaching, copied to the word in the format of 1-1-2-1- coaching [1], unit 1 - class 1 class -2 -1 review review - 1st DIP 92 93 = n-1 the For the To the UBound (classes) 94 classes the If (n-) <> "" the Then 95 wordApp.Documents.Open (classes(n)) 96 96 97 End the If 98 the Next 99 End the If 100 the Next 101 '. 1 the To the UBound the For X = (classes) 102' the If classes (X) <> "" the Then 103 'reg.Global = True' global matching 104 'reg.IgnoreCase = True' ignore case 105 'reg.Pattern = "(*)? _ 101. * '" regular expressions 106' set myMatches = reg.Execute (classes (x)) ' to return to the result of the matching set myMatches 107' For Each myMatch in myMatches 'iterate myMatches set 108' myMatch IF <> "" the Then 109 'the Debug.Print (classes (X)) 110' End IF 111 'the Next 112' 113 'End IF 114' the Next 115 1 16 End Sub
Description (2017.3.26):
1. not finished, writes the new folder, and the next new word, rename, find coaching, the coaching copied into it, because it will give coaching number should be a lot of trouble
Public Sub test1. 1 () 2 Dim path . 3 Dim filename . 4 Dim Folders (the To 100. 1) . 5% Dim I, J% . 6 = I. 1 . 7. 1 J = . 8 '1. get all the folders to 9 path = ThisWorkbook. & path "\ oriFolder \" 10 folders (. 1) = path . 11 'here and in the following classes folders array array 100 is provided only in length, for the convenience of debugging, or sometimes a large number of blank lines, can be increased in practice . 12 'dir second called with no arguments, returns to the same folder under the second file! ! 13 'filename = Dir (folders ( i), vbDirectory) where filename is acquired first file in the folders (1) path to the folder. "" 14' first folder to find the dir. "", Then i = 1, enters a do loop, the oriFolder this layer folders dir out (101 and 102), 15 'to find a folder put j by 1 (the last j = 3), the folders (i) is modified. "" path , 101 and 102 route path, inside the loop will do until do such a thing 16 'do an until then done, I add to the 1, 2 becomes, when the filename = dir (folders (i) , vbDirectory), folders (2) is to do until the cycle has been modified in a path 101, 17 'continue to do until loop, j = 3 at present, and then began to increase, the purpose is to make folders (j) to continue in the future to increase the array of elements, such as the 101 after all the folders in the path of the path added to it, 18' i becomes 3, 102 then begins to traverse the folder 19 'if there is also folders 101, 101 and 102 on the other to traverse are completed, because each increase of only 1 i, and j as long as there is a folder is incremented, 20' so As long as the number of j i no that would have been traversed go down and take out all the subfolders traverse 21 the Do the While i <= j 22 filename = Dir (Folders (i), vbDirectory) 'filename = "." 23 the Do the Until filename = "" 24 the if the InStr (filename, ".") = 0 the Then 25 J = J +. 1 26 is' when i = 1, when the folders (j) 1,2,3 are ",", the directory 101 27 folders (j) = folders ( 30 Loop 31 i = i + 1 32 Loop 28 End If The Dir filename = 29 53 Loop 33 is 'P = the For the To the UBound. 1 (Folders) 34 is' the If Folders (P) <> "" the Then 35 'the Debug.Print (Folders (P)) 36' End the If 37 [ 'the Next 38 is' 2. From each folder Get all courses in, into an array 39 Dim classes (the To 100. 1) 40 Dim class 41 is Dim P 42 is Dim Q 43 is P =. 1 44 is Q =. 1 45 46 is the To the UBound the For P =. 1 (Folders) 47 Folders the If (P ) <> "" the Then 48 the Dir = class (Folders (P) & "*. *") 49 the Until the Do class = "" 50 classes (Q) = Folders (P) &class 51 q = q + 1 52 class = Dir 54 End If 55 Next 56 57 58 '3. desFolder in the new folder, generating coaching RTF 59 Dim path2 60' to the first set of canonical correlation AS Dim 61 is of As the RegExp Dim REG 62 is the MatchCollection Dim myMatches of As 63 is Dim myMatch match of As 64 Dim Books (the To. 1 10 ) 65 Dim bnum 66 m Dim 67 Dim n- 68. 1 = n- 69. 1 m = 70. 1 bnum = 'again set the operation word 71 is AS Dim 72 Dim wordApp the Word.Application of As 73 is the set New wordApp the Word.Application = 74 = path2 & ThisWorkbook.path "\ desFolder \" 75 the Set New RegExp REG = 76 'get all versions of the folder name 77 filename2 = Dir (path, vbDirectory) 78 the Do the Until filename2 = "" 79 the If the InStr (filename2, ".") = 0 the Then 80 Books (bnum) = filename2 81 bnum = bnum +. 1 82 End the If 83 filename2 = the Dir 84 Loop 85 'generates a version of the folder desFolder inside 86 For m = 1 To the UBound (Books) 87 'Books (m) is not empty, and the folder does not exist, a new folder 88 If books (m) <> "" and Dir (path2 & books (m), vbDirectory) = "" Then the MkDir 89 (path2 & Books (m)) 90 'new word, named "01_" stars "_DianBo.doc" 91 is' open each class, find coaching, copied to the word in the format of 1-1-2-1- coaching [1], unit 1 - class 1 class -2 -1 review review - 1st DIP 92 93 = n-1 the For the To the UBound (classes) 94 classes the If (n-) <> "" the Then 95 wordApp.Documents.Open (classes(n)) 96 97 End the If 98 the Next 99 End the If 100 the Next 101 '. 1 the To the UBound the For X = (classes) 102' the If classes (X) <> "" the Then 103 'reg.Global = True' global matching 104 'reg.IgnoreCase = True' ignore case 105 'reg.Pattern = "(*)? _ 101. * '" regular expressions 106' set myMatches = reg.Execute (classes (x)) ' to return to the result of the matching set myMatches 107' Each myMatch the For the in myMatches' iterate myMatches collection 108 'the If myMatch <> "" the Then 109' the Debug.Print (classes (X)) 110 'End the If 111' the Next 112 ' 113' End the If 114 'the Next 115 1 16 End Sub