回答編集履歴
1
追記
test
CHANGED
@@ -36,6 +36,14 @@
|
|
36
36
|
|
37
37
|
```vb
|
38
38
|
|
39
|
+
Dim SHE As Object
|
40
|
+
|
41
|
+
Dim QIT As Object
|
42
|
+
|
43
|
+
Dim CIG As Integer
|
44
|
+
|
45
|
+
|
46
|
+
|
39
47
|
Set SHE = CreateObject("Shell.Application")
|
40
48
|
|
41
49
|
For CIG = SHE.Windows.Count To 1 Step -1
|
@@ -53,3 +61,73 @@
|
|
53
61
|
|
54
62
|
|
55
63
|
```
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
追記
|
68
|
+
|
69
|
+
---
|
70
|
+
|
71
|
+
手動でIEを開いて、上記のコードを実行するとエラーなくIEが閉じます。ということは、このコード自体に問題はないということです。
|
72
|
+
|
73
|
+
> 回答有難うございます。実はそちらの手法を既に試したのですが、タスクマネージャーを開いて見るとIEのプロセスが残ったままでした。
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
質問のコードで、IEを開くところのみ抜き出してみると、下記のようになります。
|
78
|
+
|
79
|
+
```
|
80
|
+
|
81
|
+
Dim interNet5 As InternetExplorer
|
82
|
+
|
83
|
+
Dim interNet4 As InternetExplorer
|
84
|
+
|
85
|
+
Dim interNet3 As InternetExplorer
|
86
|
+
|
87
|
+
Dim interNet2 As InternetExplorer
|
88
|
+
|
89
|
+
Dim interNet As InternetExplorer
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Set interNet2 = CreateObject("Internetexplorer.Application")
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
For Each EL In Colect
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
Set interNet3 = CreateObject("Internetexplorer.Application")
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
Set interNet4 = CreateObject("Internetexplorer.Application")
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
For Each ELD In Colect3
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
Set interNet5 = CreateObject("Internetexplorer.Application")
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
Next ELD
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
Next EL
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
Forループの中で何度も CreateObject して、同じ変数に代入しています。
|
126
|
+
|
127
|
+
繰り返し代入する前に、ちゃんと Quit で閉じる処理をしてますか。
|
128
|
+
|
129
|
+
閉じないで代入してしまうと、その IE は幽霊となってしまって、プログラムからは制御できなくなります。
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
想定外の動きをするときに、その原因をつきとめてそこで解決せずに、別の手段に逃げるのは本質的な解決にはなりません。
|