VBA IE getElementById ไม่ทำงาน

ฉันมีปัญหากับ getElementById มันทำงานไม่ถูกต้อง เมื่อฉันดำเนินการมันไม่รอจนกว่าเงื่อนไขจะเป็นเท็จ นี่คือรหัส VBA ของฉัน:

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>

หรือมีวิธีใดในการกำหนดสไตล์แท็ก?


person Sunil    schedule 19.09.2014    source แหล่งที่มา


คำตอบ (1)


หากคุณกำลังรอให้เพจโหลด ให้ใช้วิธีไม่ว่าง นี่คือตัวอย่าง:

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

นั่นช่วยได้ไหม?

person Nicholas Ibarra    schedule 19.09.2014
comment
มันไม่ทำงานเพราะเพจของฉันกำลังโหลดบางส่วน ดังนั้นเมื่อฉันใช้วิธีการไม่ว่าง วิธีการไม่ทำงานเช่นเดียวกับวิธี wb.Readystate ก็ไม่ทำงานในสถานการณ์นี้เช่นกัน - person Sunil; 20.09.2014