2014-09-19 122 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