vba操作IE浏览器
Set objShell = CreateObject("Shell.Application")
For n = 1 To objShell.Windows.count
??? Set objie = objShell.Windows(n)
??? If Right(UCase(objie.FullName), 12) = "IEXPLORE.EXE" Then
??????? If (0 < InStr(objie.LocationURL, "要訪問的地址(http://localhost:8080/test/login.jsp)")) Then
????????? 'objie 就是要訪問的ie對象
??????? end if
??? end if
next n
'打開頁面
'方法一
objie.navigate(ipAddress, 1, "ExcelSubmitWin")
'方法二 非active打開
objie.navigate2(ipAddress, &H1000, "ExcelSubmitWin")
'設置頁面項目的值 (頁面的boolean類型可以直接賦值TRUE)
objie.Document.GetElementById("userID").Value = "root"
'多條數(shù)據(jù)設置
??? web頁面List項目
??? <ui:repeat id="recordList" value="#{testDto.records}" var="rcd">
??????? <h:inputHidden id="recordData" value="#{rcd.content}" />
?? </ui:repeat>
??? vba訪問web頁面List項目
?? For i = 0 To count
?????? dataID = "sendForm:recordList:" & i "recordData"
?????? objie.Document.GetElementById(dataID).Value = “strContent”
?? next
?? 如果strContent又是List類型,將strContent中數(shù)據(jù)用特殊符號隔開拼接成字符串,然后java側再解析
'觸發(fā)頁面按鈕
objie.Document.GetElementById("buttonID").Click
'等待請求終了
Do While objie.Busy
?? DoEvents
Loop
'等待畫面刷新完了
Do While objie.Document.readystate <> "complete"
??? DoEvents
Loop
總結
以上是生活随笔為你收集整理的vba操作IE浏览器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python中tk表格控件的属性_[py
- 下一篇: mysql的设置更改root密码、连接、