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"
'多條數據設置
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中數據用特殊符號隔開拼接成字符串,然後java側再解析
'觸發頁面按鈕
objie.Document.GetElementById("buttonID").Click
'等待請求終了
Do While objie.Busy
DoEvents
Loop
'等待畫面刷新完了
Do While objie.Document.readystate <> "complete"
DoEvents
Loop