Dear. I want to replace the html contents in IE using COM module functions, However, The following functions doesn't work well. Please check the following functions for replacing the html contents as effect. Best regards. int CCommonInfo::PutStringTOIW(IWebBrowser2 *mWeb, CString strReplace) { IHTMLDocument2 *Document; IDispatch *Dispatch; HRESULT Result; CString strHtml; IHTMLElement *m_pBody; IHTMLElement *lpParentElm; IStream* pStream = NULL; // HGLOBAL hHTMLText; Result = mWeb->get_Document(&Dispatch); if (FAILED(Result) || Dispatch == NULL) return -1; Result = Dispatch->QueryInterface(IID_IHTMLDocument2, (void **) &Document); Dispatch->Release(); if (FAILED(Result)) return -1; if (Document) { // Get the BODY object Result = Document->get_body(&m_pBody); Document->Release(); Document = NULL; if (FAILED(Result) || !m_pBody) return Result; // Get the HTML text BSTR bstrHTMLText = strReplace.AllocSysString(); // the parent of BODY is HTML m_pBody->get_parentElement(&lpParentElm); lpParentElm->put_outerHTML((BSTR)bstrHTMLText); m_pBody->Release(); lpParentElm->Release(); lpParentElm = NULL; m_pBody = NULL; Document = NULL; Dispatch = NULL; ::SysFreeString (bstrHTMLText); } return strOrg.GetLength() ; }