I have created a ribbon for Powerpoint with visual studio XML ribbon. This ribbon has a button that, simplifying, does this:
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")