回答編集履歴
1
VBAコードの追記
test
CHANGED
@@ -6,7 +6,185 @@
|
|
6
6
|
|
7
7
|
コードは読んでいませんが、単純に考えられるのはメモリリークとかでしょうか。
|
8
8
|
|
9
|
-
|
9
|
+
例えば30回毎にieオブジェクトを破棄して、改めてCreateObjectするようにしたら改善するかもしれません。
|
10
|
+
|
11
|
+
```VBA
|
12
|
+
|
13
|
+
Private Function urlscr(btAry As String)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
Application.ScreenUpdating = False
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
Dim i As Long
|
22
|
+
|
23
|
+
Dim urlLen As Long
|
24
|
+
|
25
|
+
Dim urlStr() As String
|
26
|
+
|
27
|
+
Dim tAry() As String
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
urlStr() = Split(btAry, ",")
|
32
|
+
|
33
|
+
urlLen = UBound(urlStr)
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
ReDim tAry(urlLen, 1) As String
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
For i = 0 To urlLen - 1
|
42
|
+
|
43
|
+
tAry(i, 0) = urlStr(i)
|
44
|
+
|
45
|
+
Sleep (1)
|
46
|
+
|
47
|
+
Next
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
Dim ie As InternetExplorer
|
52
|
+
|
53
|
+
Dim htdoc As HTMLDocument
|
54
|
+
|
55
|
+
Dim tagName As HTMLElementCollection
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
'変更箇所 ここから
|
60
|
+
|
61
|
+
Const ResetPages = 30
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
For i = 0 To urlLen - 1
|
66
|
+
|
67
|
+
If i Mod ResetPages = 0 Then
|
68
|
+
|
69
|
+
If Not ie Is Nothing Then
|
70
|
+
|
71
|
+
ie.Quit
|
72
|
+
|
73
|
+
End If
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
Set ie = CreateObject("InternetExplorer.Application")
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
ie.Visible = True
|
82
|
+
|
83
|
+
ie.Top = True
|
84
|
+
|
85
|
+
ie.Left = True
|
86
|
+
|
87
|
+
ie.Width = 500
|
88
|
+
|
89
|
+
ie.Height = 500
|
90
|
+
|
91
|
+
End If
|
92
|
+
|
93
|
+
'変更箇所 ここまで
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
Debug.Print i & " / " & urlLen - 1
|
98
|
+
|
99
|
+
ie.Navigate tAry(i, 0)
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
Do While ie.Busy Or ie.ReadyState < READYSTATE_COMPLETE
|
104
|
+
|
105
|
+
DoEvents
|
106
|
+
|
107
|
+
Loop
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
Set htdoc = ie.document
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
If InStr(htdoc.Url, "") > 0 Then
|
116
|
+
|
117
|
+
For Each tagName In htdoc.getElementsByClassName("")
|
118
|
+
|
119
|
+
If InStr(tagName.outerText, "") > 0 Then
|
120
|
+
|
121
|
+
tAry(i, 1) = "×"
|
122
|
+
|
123
|
+
Exit For
|
124
|
+
|
125
|
+
End If
|
126
|
+
|
127
|
+
Next
|
128
|
+
|
129
|
+
End If
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
Set htdoc = Nothing
|
136
|
+
|
137
|
+
Set tagName = Nothing
|
138
|
+
|
139
|
+
Sleep 1
|
140
|
+
|
141
|
+
Next
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
ie.Quit
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
Set ie = Nothing
|
150
|
+
|
151
|
+
Set htdoc = Nothing
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
Dim num As Long
|
156
|
+
|
157
|
+
Dim ws As Worksheet
|
158
|
+
|
159
|
+
Set ws = ActiveSheet
|
160
|
+
|
161
|
+
num = ws.Cells(1, 1).CurrentRegion.Rows.Count - 1
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
For i = 0 To num - 2
|
166
|
+
|
167
|
+
If ws.Cells(i + 2, 1).Value = tAry(i, 0) Then
|
168
|
+
|
169
|
+
ws.Cells(i + 2, 3).Value = tAry(i, 1)
|
170
|
+
|
171
|
+
End If
|
172
|
+
|
173
|
+
Sleep 1
|
174
|
+
|
175
|
+
Next
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
Set ws = Nothing
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
End Function
|
184
|
+
|
185
|
+
```
|
186
|
+
|
187
|
+
|
10
188
|
|
11
189
|
|
12
190
|
|