回答編集履歴

1

修正

2020/08/07 01:15

投稿

mattuwan
mattuwan

スコア2136

test CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  'ファイルフルパス一覧取得
38
38
 
39
- GetFileList strFolder, ix
39
+ GetFileList mFSO.GetFolder(strFolder), ix
40
40
 
41
41
  End Sub
42
42
 
@@ -70,43 +70,45 @@
70
70
 
71
71
  'ファイル一覧取得(サブフォルダ含む)
72
72
 
73
- Private Function GetFileList(ByVal sPath As String, ByRef i As Long) As Boolean
73
+ Private Function GetFileList(ByVal objFolder As Folder, ByRef i As Long) As Boolean
74
74
 
75
- Dim objFolder As Folder
75
+ Dim fo As Folder
76
76
 
77
- Dim objFile As File
77
+ Dim fi As File
78
78
 
79
79
 
80
80
 
81
- For Each objFolder In mFSO.GetFolder(sPath).SubFolders
81
+ For Each fo In objFolder.SubFolders
82
82
 
83
- GetFileList objFolder.Path, i
83
+ GetFileList fo, i
84
+
85
+ Next
84
86
 
85
87
 
86
88
 
87
- For Each objFile In objFolder.Files
89
+ For Each fi In objFolder.Files
88
90
 
89
- If mFSO.GetExtensionName(objFile) Like "xls?" Then
91
+ If mFSO.GetExtensionName(fi) Like "xls?" Then
90
92
 
91
- i = i + 1
93
+ i = i + 1
92
94
 
93
- With mRng(i, 1)
95
+ With mRng(i, 1)
94
96
 
95
- .Worksheet.Hyperlinks.Add Anchor:=.Cells, _
97
+ .Worksheet.Hyperlinks.Add Anchor:=.Cells, _
96
98
 
97
- Address:=objFile.Path, _
99
+ Address:=fi.Path, _
98
100
 
99
- TextToDisplay:=objFile.Name
101
+ TextToDisplay:=fi.Name
100
102
 
101
- End With
103
+ End With
102
104
 
103
- End If
105
+ End If
104
-
105
- Next
106
106
 
107
107
  Next
108
108
 
109
109
  End Function
110
+
111
+
110
112
 
111
113
 
112
114
 
@@ -156,14 +158,12 @@
156
158
 
157
159
 
158
160
 
159
- あと、ループの仕方も違いますが、その辺はお好みで。
160
-
161
- 出力される順番が違ってくるかも知れませんが。
162
-
163
-
164
-
165
161
  ※簡単な動作確認はしてますが、
166
162
 
167
163
  もれなくリストアップされるかは確認してませんので、
168
164
 
169
165
  間違いがないか自己責任でお願いします。
166
+
167
+
168
+
169
+ ※コードに不具合があったので修正しました。