Error: Class or COM interface type expected, but got "OleVariant" lazarus / 34-Windows ---------------------------------------------------------------------- Aidex · 2018-12-30 07:57 Hi! When compiling the following code (using Lazarus 1.8.4) I get this error message in the last line for the "as"-operator: Class or COM interface type expected, but got "OleVariant". IHTMLDocument2 is defined in the unit MSHTML_4_0_TLB as interface(IHTMLDocument) What do I need to change? Thank you in advance. uses ComObj, MSHTML_4_0_TLB; procedure Test(); var Browser: OleVariant;     Doc: IHTMLDocument2; // from MSHTML_4_0_TLB begin  Browser := CreateOleObject('InternetExplorer.Application');  Doc := Browser.ComServer.Document as IHTMLDocument2; end;