function SaveHTMLToStream(Astream:TStream):HResult;
var
IpStream:IpersistStreamInit;
begin
with WebBrower2 do
begin
while ReadState<>READYSTATE_COMPLETE do
Forms.Application.ProcessMessages;
if Assigned(Document) then
begin
IpStream :=Document as IPersistStreamInit;
Result :=IpStream.Save(TStreamAdapter.Create(AStream),TRUE);
end
else
Result :=S_FALSE;
end;
end;