2014-09-19 118 views
1

我遇到了getElementById問題,它工作不正常。當我執行它不會等到條件爲假。 這是我的VBA代碼:VBA IE getElementById不工作

If IE.Document.getElementById("ReportViewerControl_AsyncWait_Wait").Style.visibility = "visible" Then 
    Application.Wait (Now + TimeValue("0:00:02")) 
End If 

HTML代碼

<DIV id=ReportViewerControl_AsyncWait style="CLIP: rect(0px 1914px 142px 0px); HEIGHT: 144px; WIDTH: 1916px; POSITION: absolute; LEFT: 0px; FILTER: alpha(opacity=70); Z-INDEX: 1000; DISPLAY: none; TOP: 246px; VISIBILITY: visible; BACKGROUND-COLOR: white; opacity: 0.7" control="[object Object]" _oldDisplayMode="block"></DIV> 

或者是有任何的方式來定義風格的標籤?

回答

0

如果您正在等待頁面加載,請使用繁忙方法。這裏有一個例子:

Dim wb As Object 
Dim doc As Object 

Set wb = CreateObject("InternetExplorer.Application") 

'Address of site 
wb.navigate "http://stackoverflow.com/" 
wb.Visible = True 

'Waits for page to load 
While wb.busy 
    DoEvents 
Wend 

這有幫助嗎?

+1

它不工作,因爲我的頁面部分加載,所以當我使用繁忙的方法不工作,以及'wb.Readystate'方法不工作在這種情況下也不工作。 – Sunil 2014-09-20 10:11:33