title: Editing and saving local HTML file using TWebBrowser
body: <p>I'm trying to load a local HTML file in <code>TWebBrowser</code>, edit the content and save it.</p>
  
  <p>I've read some suggestions from <a href="http://delphi.cjcsoft.net/viewthread.php?tid=46686" rel="nofollow noreferrer">this</a> article and tried as follows:</p>
  
  <p><strong>1) Loading the document:</strong></p>
  
  <pre><code>procedure TForm1.FormCreate(Sender: TObject);
  begin
    WebBrowser1.Navigate('file:///C:\Tmp\input.html');
  end;
  </code></pre>
  
  <p><strong>2) Putting the component in editable mode:</strong></p>
  
  <p>In the <code>TWebBrowser.OnDocumentComplete</code> event handler:</p>
  
  <pre><code>procedure TForm1.WebBrowser1DocumentComplete(ASender: TObject;
    const pDisp: IDispatch; const URL: OleVariant);
  begin
    (WebBrowser1.Document as IHTMLDocument2).designMode := 'on';
  end;
  </code></pre>
  
  <p>At this point, the component is editable and I can modify its text.</p>
  
  <p><strong>3) Saving the edited document:</strong></p>
  
  <pre><code>procedure TForm1.Button1Click(Sender: TObject);
  var
    Stream : TStringStream;
  begin
    (WebBrowser1.Document as IHTMLDocument2).designMode := 'no';
  
    Stream := TStringStream.Create((WebBrowser1.Document as IHtmlDocument2).body.innerHTML);
    try
      Stream.SaveToFile('C:\Tmp\output.html');
    finally
      Stream.Free;
    end;
  end;
  </code></pre>
  
  <p>At the first line, an <code>EOleException</code> is raised:</p>
  
  <p><a href="https://i.stack.imgur.com/gDJxA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gDJxA.png" alt="Picture displaying the EOleException message dialog in italian language, saying: &#39;Impossibile ottenere la proprietà designMode. Argomento non valido&#39;"></a></p>
  
  <p>In english it should be something like:</p>
  
  <blockquote>
    <p>Cannot get designMode property. Invalid argument</p>
  </blockquote>