Exception 0x800A01B6 using getElementById after the first load

前端 未结 1 1494
臣服心动
臣服心动 2020-12-22 08:00

I have created a ribbon for Powerpoint with visual studio XML ribbon. This ribbon has a button that, simplifying, does this:

  • opens an IE browser
  • searc
相关标签:
1条回答
  • 2020-12-22 08:36

    The type of the Document property is only resolved at run-time, so it's an Object until then. This is why calling any methods in it results in the so-called late binding - you do not yet know if the getElementById method exists or not, so that has to be determined a run-time.

    You most likely get the error because the Document is not of the IHTMLDocument3 type, which is the only document type that includes the getElementById method.

    What you can try is casting the Document to an IHTMLDocument3 interface. Since it inherits IHTMLDocument and IHTMLDocument2 you can cast between them even if the document is actually one of the earlier types.

    DirectCast(ie.Document, IHTMLDocument3).getElementById("hdnstring")
    
    0 讨论(0)
提交回复
热议问题