回答編集履歴

1

追記

2017/11/30 23:54

投稿

ttyp03
ttyp03

スコア16996

test CHANGED
@@ -15,3 +15,61 @@
15
15
  詳しくはこちらを参照。
16
16
 
17
17
  [https://kuroeveryday.blogspot.jp/2013/10/FileSystemObjectSort.html](https://kuroeveryday.blogspot.jp/2013/10/FileSystemObjectSort.html)
18
+
19
+
20
+
21
+ 追記
22
+
23
+ Dir関数で行うということでしたので、ソート処理について追記しておきます。
24
+
25
+ ファイル名をため込むのには、配列を使うよりもArrayListを使うと便利です。
26
+
27
+ とりあえずバックアップフォルダー内の処理だけ書き換えてみましたので参考にどうぞ。
28
+
29
+ ```VBA
30
+
31
+ Dim intFileCNT As Integer
32
+
33
+ Dim strFileName As String
34
+
35
+ intFileCNT = 0
36
+
37
+
38
+
39
+ 'バックアップフォルダー内のファイル数をカウント
40
+
41
+ Dim strBackupFileNames As Object
42
+
43
+ Set strBackupFileNames = CreateObject("System.Collections.ArrayList")
44
+
45
+ strFileName = Dir("フォルダパス")
46
+
47
+ While strFileName <> ""
48
+
49
+ strBackupFileNames.Add strFileName
50
+
51
+ If Left(strFileName, 8) = "FILENAME" Then
52
+
53
+ intFileCNT = intFileCNT + 1
54
+
55
+ End If
56
+
57
+ strFileName = Dir()
58
+
59
+ Wend
60
+
61
+ strBackupFileNames.Sort
62
+
63
+
64
+
65
+ ' 確認
66
+
67
+ For Each tmp In strBackupFileNames
68
+
69
+ Debug.Print tmp
70
+
71
+ Next
72
+
73
+
74
+
75
+ ```