标题: 如何写一个函数关闭指定的IE窗口? [打印本页] 作者: gjay1688 时间: 2010-2-24 11:06 标题: 如何写一个函数关闭指定的IE窗口? 如何写一个函数关闭指定的IE窗口?作者: zzxxbb112 时间: 2010-2-24 11:07
Browser().close作者: 风雪夜归人 时间: 2010-2-24 12:34
Sub CloseIE(strIETitle)
Set shell = CreateObject("Shell.Application")
Set shellWindows = shell.Windows
For Each ie In shellWindows
If InStr(1, ie.FullName, "IEXPLORE.EXE", vbTextCompare) <> 0 then
If Instr(1, Window("hwnd:=" &ie.HWND).GetROProperty("text"), strIETitle, vbTextCompare) <> 0 Then
SystemUtil.CloseProcessByHwnd ie.HWND
End If
End if
Next
End Sub
Sub CloseIE(strIETitle)
Set shell = CreateObject("Shell.Application")
Set shellWindows = shell.Windows
For Each ie In shellWindows
Msgbox ie.fullname
Next
End Sub作者: gjay1688 时间: 2010-2-24 14:13
可是既然是ie.FullName,不就肯定是IEXPLORE.EXE吗?不需要判断吧。作者: 风雪夜归人 时间: 2010-2-24 14:44
For Each ie In shellWindows 注意这句话,ie仅仅是我定义的一个在shellWindows里面的一个实体,而不是传说中的internetexplorer,或者说如果我这样定义 For Each aaaa In shellWindows 则用: aaa. FullName作者: gjay1688 时间: 2010-2-24 15:16
知道了,多谢指教。作者: gjay1688 时间: 2010-2-24 15:34
但是为什么我用下面的代码,显示的都是IE而没有其他程序呢?
Set shell = CreateObject("Shell.Application")
Set shellWindows = shell.Windows
For Each aaa In shellWindows
Msgbox aaa.fullname
Next作者: 风雪夜归人 时间: 2010-2-24 16:08
会有的,只是没有特定的环境而已~作者: wangsc_testing 时间: 2010-2-25 21:04
InStr 函数用于返回某字符串在另一字符串中第一次出现的位置。
格式如下:
InStr([start, ]string1, string2[, compare])