Dim ie_obj As Object
Dim ObjShell As Object
Dim ObjWindow As Object
Dim WinExist As Boolean
Dim WinPage As String
WinExist = False
Set ObjShell = CreateObject(“Shell.Application”)
For Each ObjWindow In ObjShell.Windows
If TypeName(ObjWindow.Document) = “HTMLDocument” Then
WinExist = True
Set ie_obj = ObjWindow
If ie_obj.locationName = “Google” Then
WinPage = “opend”
End If
End If
Next
Set ObjShell = CreateObject(“Shell.Application”)
For Each ObjWindow In ObjShell.Windows
If TypeName(ObjWindow.Document) = “HTMLDocument” Then
WinExist = True
Set ie_obj = ObjWindow
If ie_obj.locationName = “Google” Then
WinPage = “opend”
End If
End If
Next
‘ WinExist、IEが起動していたらTrueにするが、最初はFalse
‘ For Each でウィンドウがある限り繰り返し処理
‘ そのウィンドウのドキュメントタイプがHTMLかどうか
‘ HTMLならIEなのでWinExistにTrueを代入
‘ 見つけたIEをオブジェクトに代入
‘ さらに、そのロケーションネーム(タイトル)がGoogleかどうか
‘ GoogleならWinPageを”opened”にする
WinExist や WinPage なんてのはあってもなくても良いけど、
「IEが起動していなければ立ち上げる」とか
「IEは起動しているけど、目的のページ(タイトル)ではないから移動する」とか
そんな条件分岐に使ったりしても良いかと。
また、「locationName」を「locationURL」とすればURLを取得できるので、特定のURLを探し出したりすることもできる。
他にも
ie_obj.Name
ie_obj.Path
ie_obj.FullName
ie_obj.Width
ie_obj.Height
ie_obj.Left
ie_obj.Top
ie_obj.Path
ie_obj.FullName
ie_obj.Width
ie_obj.Height
ie_obj.Left
ie_obj.Top
名前(Internet Explorer と入る)
パス(ディレクトリ名まで)
フルパス(ファイル名まで)
ウィンドウの横幅
ウィンドウの高さ
ウィンドウの左端からの位置
ウィンドウの上端からの位置
パス(ディレクトリ名まで)
フルパス(ファイル名まで)
ウィンドウの横幅
ウィンドウの高さ
ウィンドウの左端からの位置
ウィンドウの上端からの位置
といった感じで情報を取得できる。