Sub All_IE_Close()
Dim ObjIE As Object
Dim ObjShell As Object
Dim ObjWindow As Object
Set ObjShell = CreateObject("Shell.Application")
'全shellをチェックしてIEならClose
For Each ObjWindow In ObjShell.Windows
If TypeName(ObjWindow.Document) = "HTMLDocument" Then ObjWindow.Quit
Next
'1だけメインのIEを起動する
Set ObjIE = CreateObject("InternetExplorer.application")
ObjIE.Visible = True
ObjIE.Navigate "http://xxxxxxxxxx"
End Sub
Sub Go()
Dim ObjIE As Object
Dim ObjShell As Object
Dim ObjWindow As Object
Dim wkTEXT As String, intISR As Integer
Dim txtISR As String, intEnd As Integer, Y As Integer
Set ObjShell = CreateObject("Shell.Application")
'全shellをチェック
For Each ObjWindow In ObjShell.Windows
'IEならば
If TypeName(ObjWindow.Document) = "HTMLDocument" Then
Set ObjIE = ObjWindow
'フィールドに値をセット&クリック&3秒待ち
ObjIE.Document.forms(1).Item("xxxx").Value = "xxx"
ObjIE.Document.all("xxxxx").click
Application.Wait Time:=Now + TimeValue("00:00:03")
'結果HTMLから必要な文字列の取り出し
wkTEXT = ObjIE.Document.body.innerText
intISR = InStr(1, wkTEXT, "ISR ")
intEnd = InStr(1, wkTEXT, "xxxx")
'値が見つかれば
If intISR > 0 Then
txtISR = Trim(Mid(wkTEXT, intISR + 4, intEnd – intISR – 6))
Debug.Print txtISR
End If
'強制終了
MsgBox "Done!"
End
End If
Next
End Sub
実行中のIEを探し制御
返信