VBA では、getElementByID("id_name") を使用し、id が存在しない場合、関数は null ではなく何も返しません。これにより、DOM がまだ要素をレンダリングしていないのか、それとも要素が本当に存在しないのかがわからないままになります。仕様では NULL を返す必要があり、NULL は Nothing と等しくないようです。だから私の質問は、この DOM 関数が NULL を返すか、何も返さないか、それとも私が見逃しているものに依存しているのかということです。ありがとう
スニピット
If Not IsNull(p_IE.Document.getElementById(MAIN_SR_CONTAINER)) Then
' If I do not receive NULL I want to assume that I can grab the element.
' Still, I verify that the element is not Nothing
' problem is that NULL <> Nothing so if the element does not exist my code loops for eternity
' I do look at the readystate of the p_IE object and wait till it = 4
' But the elements may be being created by embedded javascript on the fly
Set elMainSRContainer = p_IE.Document.getElementById(MAIN_SR_CONTAINER)
Do While elMainSRContainer Is Nothing
Set elMainSRContainer = p_IE.Document.getElementById(MAIN_SR_CONTAINER)
Loop
:
:
Else
' bail
End If