Recent

Author Topic: Error: Class or COM interface type expected, but got "OleVariant"  (Read 1067 times)

Aidex

  • New Member
  • *
  • Posts: 24
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;
« Last Edit: December 31, 2018, 08:21:18 am by Aidex »