質問編集履歴

1

コードに追記

2020/10/10 03:52

投稿

KANNORYUJI
KANNORYUJI

スコア7

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,128 @@
1
+ ```ここに言語を入力
2
+
3
+ Sub FolderScript()
4
+
5
+
6
+
7
+ Dim strPath As String, i As Long
8
+
9
+
10
+
11
+ strPath = Range("B2").Value
12
+
13
+
14
+
15
+ Range("B3").Select
16
+
17
+ i = 3
18
+
19
+ Fileshow strPath, i
20
+
21
+
22
+
23
+ End Sub
24
+
25
+
26
+
27
+ Public Sub Fileshow(strPath, i)
28
+
29
+ Dim objFso As Object, objFolder As Object, objFile As Object
30
+
31
+ Dim objSub As Object, ws As Worksheet
32
+
33
+ Dim strList() As String
34
+
35
+
36
+
37
+ Dim rr As Range
38
+
39
+ Dim bb
40
+
41
+ Dim y As Integer
42
+
43
+ Dim col As Integer
44
+
45
+
46
+
47
+ Dim oFile As Object
48
+
49
+
50
+
51
+ Set ws = ThisWorkbook.Worksheets("FileList")
52
+
53
+ Set objFso = CreateObject("scripting.Filesystemobject")
54
+
55
+ Set objFolder = objFso.GetFolder(strPath)
56
+
57
+
58
+
59
+ Application.ScreenUpdating = False
60
+
61
+
62
+
63
+ For Each objFile In objFolder.Files
64
+
65
+ ws.Cells(i, 2) = objFso.GetBaseName(objFile.Path)
66
+
67
+ ws.Cells(i, 2).Select
68
+
69
+ ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=objFile.Path, TextToDisplay:=objFile.Name
70
+
71
+
72
+
73
+ ws.Cells(i, 3) = objFile.Type
74
+
75
+ ws.Cells(i, 4) = Int(objFile.Size / 1024)
76
+
77
+ ws.Cells(i, 5) = objFile.DateCreated
78
+
79
+ ws.Cells(i, 6) = objFile.DatelastAccessed
80
+
81
+ ws.Cells(i, 7) = objFile.DateLastModified
82
+
83
+ ws.Cells(i, 8) = objFile.ParentFolder.Path
84
+
85
+
86
+
87
+ For Each rr In ws.Cells(i, 8).Rows
88
+
89
+ bb = Split(rr, "\")
90
+
91
+ col = 9
92
+
93
+ For y = 1 To UBound(bb)
94
+
95
+ Cells(rr.Row, col) = bb(y)
96
+
97
+ col = col + 1
98
+
99
+ Next y
100
+
101
+
102
+
103
+ i = i + 1
104
+
105
+ Next rr
106
+
107
+
108
+
109
+ Next
110
+
111
+
112
+
113
+ For Each objSub In objFolder.SubFolders
114
+
115
+ Fileshow objSub.Path, i
116
+
117
+ Next
118
+
119
+
120
+
121
+ End Sub
122
+
123
+ コード
124
+
1
- Excel VBAを使ってファイルリスト作成をおこなっています。
125
+ ```Excel VBAを使ってファイルリスト作成をおこなっています。
2
126
 
3
127
  現在の課題は、5万ファイルに及ぶ大規模なリスト作成のためにこのマクロコードを使うと
4
128