|
测试操作:
1. 开一新的webpage 窗口 www.baidu.com
2. 点击任意的 url 链接 开4个新的选项卡Tabs webpage 窗口
点击第一个选项卡
3. 开一新的webpage 窗口 www.excelhome.com
4. 点击任意的 url 链接 开4个新的选项卡Tabs webpage 窗口
5. 开1个新的选项卡Tabs webpage 窗口 输入 网址url : http://sp.drugadmin.com/drugWebQueryEmbed.jsp
点击第一个选项卡
6. VBA 模块 贴上以下程序
7. 执行 VBA 模块 程序
8. 成功激活指定窗口 显示页面在视试窗最上层 自动带入输入资料
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim dWinFolder As New ShellWindows
Sub 激活指定窗口()
Dim mShellwindows As New ShellWindows
' Dim ie As InternetExplorer
Set ie = New ShellWindows
'''''''''''''''''''''On Error Resume Next
For Each web In ie
If InStr(1, web.FullName, "iexplore.exe", vbTextCompare) > 0 Then
h = web.hwnd
SetForegroundWindow h
Application.Wait Now() + TimeValue("0:0:01")
SendKeys "^{TAB}", True ' Send Ctrl-Tab to IE to switch to next tab
Application.Wait Now() + TimeValue("0:0:01")
If web.LocationURL = "http://sp.drugadmin.com/drugWebQueryEmbed.jsp" Then
Exit For
End If
End If
Next
激活指定窗口虽然Tabs标签选项卡 不是显示的网页页面 仍然 可以有效的 输入资料
'''' web.Visible = True ''有无此行均可以
'''' Application.Wait Now() + TimeValue("0:0:01")
'''' web.Document.Focus = True ''有无此行均可以
web.Document.getElementById("piatscode5").Value = "20"
web.Document.getElementById("captcha").Value = "20"
End Sub
|
|