Dim objFSO ' FileSystemObject Dim objFile ' ファイル読み込み用 Dim objWshShell ' WshShell オブジェクト
If Err.Number = 0 Then Set objWshShell = WScript.CreateObject("WScript.Shell") Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") If Err.Number = 0 Then For Each FLO In objFSO.GetFolder(objWshShell.CurrentDirectory).Files path = FLO.Path If Right(path, 4) = ".txt" Then Set objFile = objFSO.OpenTextFile(path, 1) Do While objFile.AtEndOfStream <> True
' 検索ボタンクリック ie.Document.all("btnG").Click waitIE ie strURL = "https://www.google.co.jp/" If ie.LocationURL = strURL Then ie.Quit Set ie = Nothing End If Loop objFile.Close End If
Next Else WScript.Echo "ファイルオープンエラー: " & Err.Description End If
Else WScript.Echo "エラー: " & Err.Description End If
Set objFile = Nothing Set objFSO = Nothing Set objWshShell = Nothing Set ie = Nothing
End Sub
' IEがビジー状態の間待ちます Sub waitIE(ie)
Do While ie.Busy = True Or ie.readystate <> 4 WScript.Sleep 100 Loop